idlehomescreen/hscontentcontrol/src/hscontentcontrolfactory.cpp
branchRCL_3
changeset 9 f966699dea19
parent 2 08c6ee43b396
child 15 ff572dfe6d86
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    16  */
    16  */
    17 
    17 
    18 // System include files
    18 // System include files
    19 #include <ecom/ecom.h>
    19 #include <ecom/ecom.h>
    20 #include <ecom/implementationinformation.h>
    20 #include <ecom/implementationinformation.h>
       
    21 #include <aknview.h>
    21 
    22 
    22 // User include files
    23 // User include files
       
    24 #include "xnappuiadapter.h"
    23 #include "hscontentcontrolfactory.h"
    25 #include "hscontentcontrolfactory.h"
    24 #include "hscontentcontrolecomlistener.h"
    26 #include "hscontentcontrolecomlistener.h"
    25 #include "hscontentcontroluninstallmonitor.h"
    27 #include "hscontentcontroluninstallmonitor.h"
    26 
    28 
    27 // Local constants
    29 // Local constants
    58 
    60 
    59 // ----------------------------------------------------------------------------
    61 // ----------------------------------------------------------------------------
    60 // CHsContentControlFactory::NewL()
    62 // CHsContentControlFactory::NewL()
    61 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    62 //
    64 //
    63 EXPORT_C CHsContentControlFactory* CHsContentControlFactory::NewL()
    65 EXPORT_C CHsContentControlFactory* CHsContentControlFactory::NewL( 
    64     {
    66         CXnAppUiAdapter& aAdapter )
    65     CHsContentControlFactory* self = new ( ELeave ) CHsContentControlFactory();
    67     {
       
    68     CHsContentControlFactory* self = 
       
    69             new ( ELeave ) CHsContentControlFactory( aAdapter );
    66     CleanupStack::PushL( self );
    70     CleanupStack::PushL( self );
    67     self->ConstructL();
    71     self->ConstructL();
    68     CleanupStack::Pop( self );
    72     CleanupStack::Pop( self );
    69     return self;
    73     return self;
    70     }
    74     }
    86 
    90 
    87 // ----------------------------------------------------------------------------
    91 // ----------------------------------------------------------------------------
    88 // CHsContentControlFactory::CHsContentControlFactory()
    92 // CHsContentControlFactory::CHsContentControlFactory()
    89 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
    90 //
    94 //
    91 CHsContentControlFactory::CHsContentControlFactory()
    95 CHsContentControlFactory::CHsContentControlFactory( CXnAppUiAdapter& aAdapter )
       
    96     :iAdapter( aAdapter ) 
    92     {
    97     {
    93     }
    98     }
    94 
    99 
    95 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    96 // CHsContentControlFactory::~CHsContentControlFactory()
   101 // CHsContentControlFactory::~CHsContentControlFactory()
    98 //
   103 //
    99 EXPORT_C CHsContentControlFactory::~CHsContentControlFactory()
   104 EXPORT_C CHsContentControlFactory::~CHsContentControlFactory()
   100     {
   105     {
   101     iImplArray.ResetAndDestroy();
   106     iImplArray.ResetAndDestroy();
   102     iImplArray.Close();
   107     iImplArray.Close();
       
   108     
       
   109     if ( iHsContentControlUis.Count() > 0 )
       
   110         {
       
   111         for( TInt index( iHsContentControlUis.Count() - 1 ); index >= 0; --index )
       
   112             {
       
   113             CHsContentControlUi* cc( iHsContentControlUis[ index ] );
       
   114             ReleaseHsCcUi( cc );
       
   115             }
       
   116         }
       
   117 
   103     iHsContentControlUis.ResetAndDestroy();
   118     iHsContentControlUis.ResetAndDestroy();
   104     
   119     
   105 	delete iHsContentControlEComListener;
   120 	delete iHsContentControlEComListener;
   106     delete iHsContentControlUninstallMonitor;
   121     delete iHsContentControlUninstallMonitor;
   107     }
   122     }
   198             {
   213             {
   199             CHsContentControlUi* cc( iHsContentControlUis[ index ] );
   214             CHsContentControlUi* cc( iHsContentControlUis[ index ] );
   200             // ImplUid of plugin must match Sis pkg uid
   215             // ImplUid of plugin must match Sis pkg uid
   201             if ( cc && cc->ImplUid() == aPkgUid )
   216             if ( cc && cc->ImplUid() == aPkgUid )
   202                 {
   217                 {
       
   218                 ReleaseHsCcUi( cc );
   203                 iHsContentControlUis.Remove( index );
   219                 iHsContentControlUis.Remove( index );
   204                 delete cc;
   220                 delete cc;
   205                 cc = NULL;
   221                 cc = NULL;
   206                 break;
   222                 break;
   207                 }
   223                 }
   243                     innerIndex >= 0 && !done; --innerIndex )
   259                     innerIndex >= 0 && !done; --innerIndex )
   244                 {
   260                 {
   245                 CHsContentControlUi* cc( iHsContentControlUis[ innerIndex ] );
   261                 CHsContentControlUi* cc( iHsContentControlUis[ innerIndex ] );
   246                 if ( cc && cc->ImplUid() == uid )
   262                 if ( cc && cc->ImplUid() == uid )
   247                     {
   263                     {
       
   264                     ReleaseHsCcUi( cc );
   248                     iHsContentControlUis.Remove( innerIndex );
   265                     iHsContentControlUis.Remove( innerIndex );
   249                     delete cc;
   266                     delete cc;
   250                     cc = NULL;
   267                     cc = NULL;
   251                     done = ETrue;
   268                     done = ETrue;
   252                     }
   269                     }
   308                         innerIndex >= 0; --innerIndex )
   325                         innerIndex >= 0; --innerIndex )
   309                     {
   326                     {
   310                     CHsContentControlUi* cc( iHsContentControlUis[ innerIndex ] );
   327                     CHsContentControlUi* cc( iHsContentControlUis[ innerIndex ] );
   311                     if ( cc && cc->ImplUid() == uid )
   328                     if ( cc && cc->ImplUid() == uid )
   312                         {
   329                         {
       
   330                         ReleaseHsCcUi( cc );
   313                         iHsContentControlUis.Remove( innerIndex );
   331                         iHsContentControlUis.Remove( innerIndex );
   314                         delete cc;
   332                         delete cc;
   315                         cc = NULL;
   333                         cc = NULL;
   316                         innerIndex = KErrNotFound;
   334                         innerIndex = KErrNotFound;
   317                         }
   335                         }
   321             }
   339             }
   322         }
   340         }
   323     return EFalse;
   341     return EFalse;
   324     }
   342     }
   325 
   343 
       
   344 // ----------------------------------------------------------------------------
       
   345 // CHsContentControlFactory::ReleaseHsCcUi
       
   346 // ----------------------------------------------------------------------------
       
   347 //
       
   348 void CHsContentControlFactory::ReleaseHsCcUi( 
       
   349         CHsContentControlUi* aHsContentControlUi )
       
   350     {
       
   351     if ( &iAdapter && aHsContentControlUi )
       
   352         {
       
   353         RPointerArray<CAknView> views;
       
   354 
       
   355         // notify plugin about deactivation
       
   356         aHsContentControlUi->DeActivate();
       
   357         
       
   358         // get all views from HsContentControlUi
       
   359         aHsContentControlUi->Views( views );
       
   360 
       
   361         for ( TInt i=0; i<views.Count(); i++ )
       
   362             {
       
   363             CAknView* view = views[ i ];
       
   364             views.Remove( i );
       
   365             // remove/deregister/delete all views from appui
       
   366             TRAP_IGNORE( iAdapter.RemoveViewL( *view ) );
       
   367             }
       
   368 
       
   369         // reset views array
       
   370         views.Reset();
       
   371         }
       
   372     }
       
   373 
   326 // End of file
   374 // End of file