menucontentsrv/srvsrc/mcsdrmhandler.cpp
branchRCL_3
changeset 118 8baec10861af
parent 0 79c6a41cd166
child 122 6cadd6867c17
equal deleted inserted replaced
114:a5a39a295112 118:8baec10861af
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Used for receive SIM Application name, icon or 
    14 * Description:  Used for receive SIM Application name, icon or
    15 *                visibility information.
    15 *                visibility information.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    39 // CMcsDrmHandler::NewL
    39 // CMcsDrmHandler::NewL
    40 // Two-phased constructor.
    40 // Two-phased constructor.
    41 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    42 //
    42 //
    43 
    43 
    44 CMcsDrmHandler* CMcsDrmHandler::NewL( 
    44 CMcsDrmHandler* CMcsDrmHandler::NewL(
    45     CMenuSrvEng& aSrvEng,
    45     CMenuSrvEng& aSrvEng,
    46     CMenuSrvEngUtils& aUtils,
    46     CMenuSrvEngUtils& aUtils,
    47     CMcsCacheHandler& aCacheHandler )
    47     CMcsCacheHandler& aCacheHandler )
    48     {
    48     {
    49     CMcsDrmHandler* self = new( ELeave ) 
    49     CMcsDrmHandler* self = new( ELeave )
    50             CMcsDrmHandler( aSrvEng, aUtils, aCacheHandler );
    50             CMcsDrmHandler( aSrvEng, aUtils, aCacheHandler );
    51     CleanupStack::PushL( self );
    51     CleanupStack::PushL( self );
    52     self->ConstructL();
    52     self->ConstructL();
    53     CleanupStack::Pop( self );
    53     CleanupStack::Pop( self );
    54     return self;
    54     return self;
    55     }
    55     }
    56 
    56 
    57 // -----------------------------------------------------------------------------    
    57 // -----------------------------------------------------------------------------
    58 // Destructor
    58 // Destructor
    59 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    60 CMcsDrmHandler::~CMcsDrmHandler()
    60 CMcsDrmHandler::~CMcsDrmHandler()
    61     {
    61     {
    62     delete iInstallNotifier;
    62     delete iInstallNotifier;
    68 // CMcsDrmHandler::CMcsDrmHandler
    68 // CMcsDrmHandler::CMcsDrmHandler
    69 // C++ default constructor can NOT contain any code, that
    69 // C++ default constructor can NOT contain any code, that
    70 // might leave.
    70 // might leave.
    71 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    72 //
    72 //
    73 CMcsDrmHandler::CMcsDrmHandler( 
    73 CMcsDrmHandler::CMcsDrmHandler(
    74     CMenuSrvEng& aSrvEng,
    74     CMenuSrvEng& aSrvEng,
    75     CMenuSrvEngUtils& aUtils,
    75     CMenuSrvEngUtils& aUtils,
    76     CMcsCacheHandler& aCacheHandler ): 
    76     CMcsCacheHandler& aCacheHandler ):
    77     iObserversManager( aUtils ), iSrvEng( aSrvEng ),
    77     iObserversManager( aUtils ), iSrvEng( aSrvEng ),
    78     iUtils( aUtils ), iCacheHandler( aCacheHandler )
    78     iUtils( aUtils ), iCacheHandler( aCacheHandler )
    79     {
    79     {
    80     }
    80     }
    81 
    81 
    85 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    86 //
    86 //
    87 void CMcsDrmHandler::ConstructL()
    87 void CMcsDrmHandler::ConstructL()
    88     {
    88     {
    89     iScanner = CMcsDrmScanner::NewL( *this, iSrvEng, iUtils );
    89     iScanner = CMcsDrmScanner::NewL( *this, iSrvEng, iUtils );
    90 	iInstallNotifier = CMcsInstallNotifier::NewL(*this, KPSUidJavaLatestInstallation);
    90 	iInstallNotifier = CMcsInstallNotifier::NewL(
    91 
    91 	        *this, CMcsInstallNotifier::EJavaInstallNotification );
    92     }
    92 
    93 
    93     }
    94 // -----------------------------------------------------------------------------
    94 
    95 // -----------------------------------------------------------------------------
    95 // -----------------------------------------------------------------------------
    96 //    
    96 // -----------------------------------------------------------------------------
       
    97 //
    97 TInt CMcsDrmHandler::AppFolderIdL( TUid aUid )
    98 TInt CMcsDrmHandler::AppFolderIdL( TUid aUid )
    98     {
    99     {
    99     RArray<TMenuItem> mcsItems; 
   100     RArray<TMenuItem> mcsItems;
   100     CleanupClosePushL( mcsItems );
   101     CleanupClosePushL( mcsItems );
   101     
   102 
   102     TInt root;
   103     TInt root;
   103     iSrvEng.Engine().RootFolderL( root );
   104     iSrvEng.Engine().RootFolderL( root );
   104     TMenuSrvTypeAttrFilter appFilter;
   105     TMenuSrvTypeAttrFilter appFilter;
   105     appFilter.SetType( KMenuTypeApp() );   
   106     appFilter.SetType( KMenuTypeApp() );
   106     
   107 
   107     TBuf<KUidChars> uidString;
   108     TBuf<KUidChars> uidString;
   108     MenuSrvUtil::UidToStringL( aUid.iUid, uidString, 0, EHex );
   109     MenuSrvUtil::UidToStringL( aUid.iUid, uidString, 0, EHex );
   109     
   110 
   110     appFilter.SetAttr( KMenuAttrUid(), uidString );
   111     appFilter.SetAttr( KMenuAttrUid(), uidString );
   111     iSrvEng.Engine().GetItemsL( mcsItems, root, &appFilter, ETrue );
   112     iSrvEng.Engine().GetItemsL( mcsItems, root, &appFilter, ETrue );
   112     
   113 
   113     TInt folderId = KErrNotFound;
   114     TInt folderId = KErrNotFound;
   114     if (mcsItems.Count())
   115     if (mcsItems.Count())
   115         {
   116         {
   116         folderId = mcsItems[0].Parent();
   117         folderId = mcsItems[0].Parent();
   117         iCacheHandler.HandleRemoveAttribute(mcsItems[0].Id(), KMenuAttrDrmProtection);
   118         iCacheHandler.HandleRemoveAttribute(mcsItems[0].Id(), KMenuAttrDrmProtection);
   118         }
   119         }
   119     
   120 
   120     CleanupStack::PopAndDestroy( &mcsItems );
   121     CleanupStack::PopAndDestroy( &mcsItems );
   121     return folderId;
   122     return folderId;
   122     }
   123     }
   123 
   124 
   124 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   126 //     
   127 //
   127 void CMcsDrmHandler::HandleDrmEvent( TUid aUid )
   128 void CMcsDrmHandler::HandleDrmEvent( TUid aUid )
   128     {
   129     {
   129     TRAP_IGNORE(
   130     TRAP_IGNORE(
   130     		iSrvEng.Engine().AppendNotifyL( AppFolderIdL( aUid ), 
   131     		iSrvEng.Engine().AppendNotifyL( AppFolderIdL( aUid ),
   131     				RMenuNotifier::EItemAttributeChanged );
   132     				RMenuNotifier::EItemAttributeChanged );
   132     		iScanner->RemoveObserverAndScanL( aUid );
   133     		iScanner->RemoveObserverAndScanL( aUid );
   133 				);
   134 				);
   134     }
   135     }
   135 
   136 
   136 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   138 //     
   139 //
   139 void CMcsDrmHandler::HandleDrmAppEvent()
   140 void CMcsDrmHandler::HandleDrmAppEvent()
   140     {
   141     {
   141     TRAP_IGNORE( AddRemoveObserversL(
   142     TRAP_IGNORE( AddRemoveObserversL(
   142         iScanner->DrmProtectedAppArray() ) );     
   143         iScanner->DrmProtectedAppArray() ) );
   143     }
   144     }
   144 
   145 
   145 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   147 // -----------------------------------------------------------------------------
   147 //     
   148 //
   148 void CMcsDrmHandler::AddRemoveObserversL( 
   149 void CMcsDrmHandler::AddRemoveObserversL(
   149 	const RArray<TUid>& aDrmProtectedArray )
   150 	const RArray<TUid>& aDrmProtectedArray )
   150     {
   151     {
   151     iObserversManager.RemoveMissingObservers( aDrmProtectedArray );    
   152     iObserversManager.RemoveMissingObservers( aDrmProtectedArray );
   152     iObserversManager.CreateObserversL( aDrmProtectedArray, *this );
   153     iObserversManager.CreateObserversL( aDrmProtectedArray, *this );
   153     }    
   154     }
   154 
   155 
   155 // -----------------------------------------------------------------------------
   156 // -----------------------------------------------------------------------------
   156 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   157 //        
   158 //
   158 void CMcsDrmHandler::EngineEvents( TInt /*aFolder*/, TInt aEvents )
   159 void CMcsDrmHandler::EngineEvents( TInt /*aFolder*/, TInt aEvents )
   159     {
   160     {
   160     if ( aEvents & RMenuNotifier::EItemsAddedRemoved )
   161     if ( aEvents & RMenuNotifier::EItemsAddedRemoved )
   161         {
   162         {
   162         iScanner->Scan();
   163         iScanner->Scan();
   163         }    
   164         }
   164     }
   165     }
   165 
   166 
   166 // ---------------------------------------------------------
   167 // ---------------------------------------------------------
   167 // CMcsDrmHandler::HandleInstallNotifyL
   168 //
   168 // ---------------------------------------------------------
   169 // ---------------------------------------------------------
   169 //
   170 //
   170 void CMcsDrmHandler::HandleInstallNotifyL( TInt aPackageUid )
   171 void CMcsDrmHandler::HandleInstallNotifyL( TUid aPackageUid,
       
   172 		CMcsInstallNotifier::TNotificationType aNotificationType )
   171 	{
   173 	{
   172 	RArray<TUid> uids;
   174     if( aPackageUid != TUid::Null() )
   173 	CleanupClosePushL( uids );
   175         {
   174 
   176         if ( ( iScanner->DrmExpiredAppArray()).Find( aPackageUid )
   175 	Java::CJavaRegistry* javaRegistry;
   177                 != KErrNotFound )
   176 	javaRegistry = Java::CJavaRegistry::NewLC();
   178             {
   177 
   179             HandleDrmEvent( aPackageUid );
   178 	Java::CJavaRegistryEntry* regEntry = 
   180             }
   179 		javaRegistry->RegistryEntryL( TUid::Uid(aPackageUid) );
   181         else
   180 
   182             {
   181 	if( regEntry )
   183             iObserversManager.RefreshObserverL(
   182 		{
   184                     iScanner->DrmProtectedAppArray(), aPackageUid, *this );
   183 	CleanupStack::PushL( regEntry );
   185             }
   184 
       
   185 	Java::TJavaRegistryEntryType entryType = regEntry->Type();
       
   186 	
       
   187 	if ( ( entryType >= Java::EGeneralPackage ) && 
       
   188 			(entryType < Java::EGeneralApplication) )
       
   189 		{
       
   190 		//package entry
       
   191 		Java::CJavaRegistryPackageEntry* regPackageEntry = 
       
   192 					static_cast<Java::CJavaRegistryPackageEntry*>( regEntry );
       
   193 			regPackageEntry->GetEmbeddedEntries( uids );
       
   194 			}
       
   195 		else 
       
   196 			{
       
   197 			//application entry
       
   198 			uids.AppendL( regEntry->Uid() );
       
   199 			}
       
   200 		
       
   201 		CleanupStack::PopAndDestroy( regEntry );
       
   202 	    for ( TInt i = 0; i< uids.Count(); i++ )
       
   203 	        {
       
   204 	        if ( ( iScanner->DrmExpiredAppArray()).Find(uids[i]) != KErrNotFound )
       
   205 	            {
       
   206 	            HandleDrmEvent( uids[i] );
       
   207 	            }
       
   208 	        else
       
   209 	            {
       
   210 	            iObserversManager.RefreshObserverL( iScanner->DrmProtectedAppArray(), 
       
   211 	                    uids[i], *this );
       
   212 	            }
       
   213 	        }
       
   214 		}
   186 		}
   215 	else
   187 	else
   216 	    {
   188 	    {
   217 	    for ( TInt i = 0; i< iScanner->DrmProtectedAppArray().Count(); i++ )
   189 	    for ( TInt i = 0; i< iScanner->DrmProtectedAppArray().Count(); i++ )
   218 	        {
   190 	        {
   219             iObserversManager.RefreshObserverL( iScanner->DrmProtectedAppArray(), 
   191             iObserversManager.RefreshObserverL(
   220         		   iScanner->DrmProtectedAppArray()[i], *this );
   192                     iScanner->DrmProtectedAppArray(),
       
   193                     iScanner->DrmProtectedAppArray()[i],
       
   194                     *this );
   221 	        }
   195 	        }
   222 	    for ( TInt i = 0; i< iScanner->DrmExpiredAppArray().Count(); i++ )
   196 	    for ( TInt i = 0; i< iScanner->DrmExpiredAppArray().Count(); i++ )
   223 	        {
   197 	        {
   224 	        HandleDrmEvent( iScanner->DrmExpiredAppArray()[i] );
   198 	        HandleDrmEvent( iScanner->DrmExpiredAppArray()[i] );
   225 	        }	    
   199 	        }
   226 	    }
   200 	    }
   227 	
   201     }
   228 	
   202 
   229 	CleanupStack::PopAndDestroy( javaRegistry );
   203 
   230 	CleanupStack::PopAndDestroy( &uids );
   204 //  End of File
   231     }
       
   232 
       
   233 
       
   234 //  End of File