idlehomescreen/nativeuicontroller/src/ainavipanerenderer.cpp
branchRCL_3
changeset 34 5456b4e8b3a8
equal deleted inserted replaced
33:5f0182e07bfb 34:5456b4e8b3a8
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Navipane renderer.
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <centralrepository.h>
       
    20 #include <ProfileEngineSDKCRKeys.h>
       
    21 
       
    22 // User includes
       
    23 #include <hscontentpublisher.h>
       
    24 #include <hspublisherinfo.h>
       
    25 
       
    26 #include "ainavipanerenderer.h"
       
    27 #include "ainavipaneanimator.h"
       
    28 #include "aistatuspanel.h"
       
    29 #include "ainativeuimodel.h"
       
    30 #include "ainativeuiplugins.h"
       
    31 #include "contentprioritymap.h"
       
    32 #include <aicontentrequest.h>
       
    33 #include "debug.h"
       
    34 
       
    35 using namespace AiNativeUiController;
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // CAiNaviPaneRenderer::ConstructL()
       
    39 //
       
    40 // ----------------------------------------------------------------------------
       
    41 //
       
    42 void CAiNaviPaneRenderer::ConstructL()
       
    43     {
       
    44     iAnimator = CAiNaviPaneAnimator::NewL( iStatusPanel, 
       
    45                                            iRenderingPriorities, 
       
    46                                            *this );
       
    47     iProfileText = HBufC::NewL(0);
       
    48     iSilentIndicator = HBufC::NewL(0);
       
    49     }
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // CAiNaviPaneRenderer::NewLC()
       
    53 //
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 CAiNaviPaneRenderer* CAiNaviPaneRenderer::NewLC( 
       
    57         CAiStatusPanel& aStatusPanel )
       
    58     {
       
    59     CAiNaviPaneRenderer* self = 
       
    60         new( ELeave ) CAiNaviPaneRenderer( aStatusPanel );
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63     return self;
       
    64     }
       
    65 
       
    66 // ----------------------------------------------------------------------------
       
    67 // CAiNaviPaneRenderer::~CAiNaviPaneRenderer()
       
    68 //
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 CAiNaviPaneRenderer::~CAiNaviPaneRenderer()
       
    72     { 
       
    73     delete iAnimator;
       
    74     delete iProfileText;
       
    75     delete iSilentIndicator; 
       
    76     delete iTimedProfileIndicator;
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CAiNaviPaneRenderer::CAiNaviPaneRenderer()
       
    81 //
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CAiNaviPaneRenderer::CAiNaviPaneRenderer( CAiStatusPanel& aStatusPanel )
       
    85     : iStatusPanel( aStatusPanel ), 
       
    86     iRenderingPriorities( AiNativeUiModel::RenderingPriorities( AiNativeUiModel::KNaviPaneId ) ),
       
    87     iCurrentContent(KAiNullContentId),
       
    88     iCurrentPriority(AiNativeUiModel::KNoPriority)
       
    89     {
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 // CAiNaviPaneRenderer::DoPublishL()
       
    94 //
       
    95 // ----------------------------------------------------------------------------
       
    96 //
       
    97 void CAiNaviPaneRenderer::DoPublishL( CHsContentPublisher& aPlugin,
       
    98     TInt aContent, const TDesC16& aText, TInt /*aIndex*/ )
       
    99     {
       
   100     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   101     
       
   102     if( info.Uid() == KDeviceStatusPluginUid )
       
   103            {
       
   104         switch( aContent )
       
   105             {
       
   106             // FALLTHROUGH
       
   107             case EAiDeviceStatusContentDate:
       
   108             case EAiDeviceStatusContentProfileName:
       
   109             case EAiDeviceStatusContentGeneralProfileName:
       
   110                 {
       
   111                 __PRINT(__DBG_FORMAT("XAI: Render navi pane - %d, %S"), aContent, &aText );
       
   112                 
       
   113                 const TInt priority = iRenderingPriorities.RenderingPriority( aContent );
       
   114                 
       
   115                 // Get active profile ID
       
   116                 CRepository* profileApi;
       
   117                 TInt         profileId;
       
   118                 profileApi = CRepository::NewL( KCRUidProfileEngine );
       
   119                 TInt err = profileApi->Get( KProEngActiveProfile, profileId );
       
   120                 delete profileApi;
       
   121 
       
   122                 if ( aContent == EAiDeviceStatusContentGeneralProfileName )
       
   123                     {
       
   124                     const TInt KGeneralProfileId( 0 );
       
   125                     if (profileId == KGeneralProfileId) 
       
   126                         {
       
   127                         iAnimator->AddItemL( EAiDeviceStatusContentGeneralIndicator, aText );
       
   128                         }
       
   129 //                    iAnimator->AddItemL( EAiDeviceStatusContentGeneralIndicator, aText );
       
   130 //                    iAnimator->AddItemL( EAiDeviceStatusContentGeneralProfileName, aText );
       
   131 
       
   132                     iAnimator->AnimateL();
       
   133                     }
       
   134 
       
   135           
       
   136                 if( (priority >= iCurrentPriority) || !iIsSilent || !iIsTimed )
       
   137                     {
       
   138                     if( priority >= iCurrentPriority )
       
   139                         {
       
   140                         delete iProfileText;
       
   141                         iProfileText = NULL;
       
   142                         iProfileText = aText.AllocL();
       
   143                         iIsOldTextChanged = ETrue;
       
   144 
       
   145                         iCurrentPriority = priority;
       
   146                         iCurrentContent = aContent;
       
   147                         }
       
   148 
       
   149                     HBufC* newText = ConstructProfileTextLC();
       
   150 
       
   151                     if( !iAnimator->IsActive() )
       
   152                         {
       
   153                         iStatusPanel.SetNaviPaneTextL( *newText );
       
   154                         iStatusPanel.RenderNaviPaneL();
       
   155                         }
       
   156                     
       
   157                     CleanupStack::PopAndDestroy( newText );
       
   158                     }            
       
   159                 
       
   160                 __PRINTS( "XAI: Render navi pane - priority check failed");
       
   161                 break;
       
   162                 }
       
   163 
       
   164             case EAiDeviceStatusContentSilentIndicator:
       
   165                 {
       
   166                 __PRINT(__DBG_FORMAT("XAI: Render navi pane - %d, %S"), aContent, &aText );
       
   167 
       
   168                 const TInt priority = iRenderingPriorities.RenderingPriority( aContent );
       
   169                 
       
   170                 if( priority >= iCurrentPriority && iIsOldTextChanged )
       
   171                     {
       
   172                     delete iSilentIndicator;
       
   173                     iSilentIndicator = NULL;
       
   174                     iSilentIndicator = aText.AllocL();
       
   175                     iIsSilent = ETrue;
       
   176                     if( !iAnimator->IsActive() )
       
   177                         {    
       
   178                         HBufC* newText = ConstructProfileTextLC();
       
   179                         iStatusPanel.SetNaviPaneTextL( *newText );
       
   180                         iStatusPanel.RenderNaviPaneL();                        
       
   181                         CleanupStack::PopAndDestroy( newText );
       
   182                         }
       
   183      
       
   184                     
       
   185 
       
   186                     
       
   187                     // iCurrentContent is not assigned because silent indicator is 
       
   188                     // rendered within the navi pane text
       
   189                     
       
   190                     __PRINTS( "XAI: Render navi pane - done");
       
   191                     }                
       
   192                 __PRINTS( "XAI: Render navi pane - priority check failed");
       
   193                 break;
       
   194                 }
       
   195             case EAiDeviceStatusContentTimedProfileIndicator:
       
   196                 {
       
   197                 __PRINT(__DBG_FORMAT("XAI: Render navi pane - %d, %S"), aContent, &aText );
       
   198 
       
   199                 const TInt priority = iRenderingPriorities.RenderingPriority( aContent );
       
   200                 
       
   201                 if( priority >= iCurrentPriority && iIsOldTextChanged )
       
   202                     {
       
   203                     delete iTimedProfileIndicator;
       
   204                     iTimedProfileIndicator = NULL;
       
   205                     iTimedProfileIndicator = aText.AllocL();
       
   206                     iIsTimed = ETrue;
       
   207                     
       
   208                     if( !iAnimator->IsActive() )
       
   209                         {    
       
   210                         HBufC* newText = ConstructProfileTextLC();
       
   211                         iStatusPanel.SetNaviPaneTextL( *newText );
       
   212                         iStatusPanel.RenderNaviPaneL();                        
       
   213                         CleanupStack::PopAndDestroy( newText );
       
   214                         }
       
   215      
       
   216 
       
   217                     // iCurrentContent is not assigned because silent indicator is 
       
   218                     // rendered within the navi pane text
       
   219                     
       
   220                     __PRINTS( "XAI: Render navi pane - done");
       
   221                     }                
       
   222                 __PRINTS( "XAI: Render navi pane - priority check failed");
       
   223                 break;
       
   224                 }                
       
   225 
       
   226             // FALLTHROUGH
       
   227             case EAiDeviceStatusContentMCNIndicator:
       
   228             case EAiDeviceStatusContentVHZIndicator:
       
   229             case EAiDeviceStatusContentCUGIndicator:
       
   230                 {
       
   231                 iAnimator->AddItemL( aContent, aText );
       
   232                 if( !iAnimator->IsActive() )
       
   233                     {
       
   234                     iAnimator->AnimateL();
       
   235                     }
       
   236                 iIsChanged = ETrue;
       
   237                 break;
       
   238                 }
       
   239 
       
   240             default:
       
   241                 {
       
   242                 User::Leave( KErrNotFound );
       
   243                 break;
       
   244                 }
       
   245             };
       
   246            }       
       
   247        else
       
   248            {
       
   249            User::Leave( KErrNotFound );    
       
   250            }
       
   251     }
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CAiNaviPaneRenderer::ConstructProfileTextLC()
       
   255 //
       
   256 // ----------------------------------------------------------------------------
       
   257 //
       
   258 HBufC* CAiNaviPaneRenderer::ConstructProfileTextLC()
       
   259     {
       
   260     TInt bufLen = iProfileText->Length();
       
   261     if ( iIsSilent )
       
   262         {
       
   263         bufLen += iSilentIndicator->Length();
       
   264         }
       
   265     if ( iIsTimed )
       
   266         {
       
   267         bufLen += iTimedProfileIndicator->Length();
       
   268         }
       
   269         
       
   270     HBufC *temp = HBufC::NewLC( bufLen );
       
   271      
       
   272     if ( iIsSilent )
       
   273         {
       
   274         temp->Des().Append( *iSilentIndicator );
       
   275         }
       
   276     if ( iIsTimed )
       
   277         {
       
   278         temp->Des().Append( *iTimedProfileIndicator );
       
   279         }
       
   280         
       
   281     temp->Des().Append( *iProfileText );
       
   282     return temp;
       
   283     }
       
   284 
       
   285 // ----------------------------------------------------------------------------
       
   286 // CAiNaviPaneRenderer::DoCleanL()
       
   287 //
       
   288 // ----------------------------------------------------------------------------
       
   289 //
       
   290 void CAiNaviPaneRenderer::DoCleanL( CHsContentPublisher& aPlugin, TInt aContent )
       
   291     {
       
   292     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   293     
       
   294     if( info.Uid() == KDeviceStatusPluginUid )
       
   295         {    
       
   296 
       
   297         switch( aContent )
       
   298             {
       
   299             case EAiDeviceStatusContentNetworkIdentity:
       
   300                 {
       
   301                 iAnimator->RemoveItem( EAiDeviceStatusContentGeneralIndicator );
       
   302                 break;
       
   303                 }
       
   304 
       
   305             // FALLTHROUGH
       
   306             case EAiDeviceStatusContentDate:
       
   307             case EAiDeviceStatusContentProfileName:
       
   308             case EAiDeviceStatusContentGeneralProfileName:
       
   309             case EAiDeviceStatusContentSilentIndicator:
       
   310             case EAiDeviceStatusContentTimedProfileIndicator:
       
   311                 {
       
   312                 __PRINT(__DBG_FORMAT("XAI: Cleaning navi pane - %d"), aContent );
       
   313                 
       
   314                 if ( aContent == EAiDeviceStatusContentSilentIndicator )
       
   315                     {
       
   316                     iIsSilent = EFalse;
       
   317                     }
       
   318                 if ( aContent == EAiDeviceStatusContentTimedProfileIndicator )
       
   319                     {
       
   320                     iIsTimed = EFalse;
       
   321                     }
       
   322                 if ( aContent == EAiDeviceStatusContentGeneralProfileName )
       
   323                     {
       
   324                     iAnimator->RemoveItem( EAiDeviceStatusContentGeneralIndicator );
       
   325 //                    iAnimator->RemoveItem( EAiDeviceStatusContentGeneralProfileName );
       
   326                     }
       
   327                 if ( aContent == EAiDeviceStatusContentProfileName )
       
   328                     {
       
   329                     iAnimator->RemoveItem( EAiDeviceStatusContentProfileName );
       
   330                     }
       
   331            
       
   332                 TInt currentPriority = iCurrentPriority;
       
   333 
       
   334                 if( iCurrentContent == aContent )
       
   335                     {
       
   336                     iCurrentContent = KAiNullContentId;
       
   337                     iCurrentPriority = AiNativeUiModel::KNoPriority;
       
   338                     
       
   339                     // Publish empty text
       
   340                     iStatusPanel.SetNaviPaneTextL( KNullDesC );
       
   341                     iStatusPanel.RenderNaviPaneL();
       
   342 
       
   343                     MAiContentRequest* contentReq = static_cast<MAiContentRequest*>(
       
   344                         aPlugin.GetProperty( CHsContentPublisher::EContentRequest ) );
       
   345                         
       
   346                     if ( contentReq )
       
   347                         {
       
   348                         TInt nextContentId;
       
   349                         while ( iRenderingPriorities.GetNextContentId( 
       
   350                                                         nextContentId, 
       
   351                                                         currentPriority ) )
       
   352                             {
       
   353                             const TBool refreshed = contentReq->RefreshContent( nextContentId );
       
   354                             if ( refreshed )
       
   355                                 {
       
   356                                 break;
       
   357                                 }
       
   358                             }
       
   359                         }
       
   360                                     
       
   361                     }                    
       
   362                 __PRINTS( "XAI: Cleaning navi pane - done");    
       
   363                 break;
       
   364                 }
       
   365 
       
   366             case EAiDeviceStatusContentMCNIndicator:
       
   367             case EAiDeviceStatusContentVHZIndicator:
       
   368             case EAiDeviceStatusContentCUGIndicator:
       
   369                 {
       
   370                 iAnimator->RemoveItem( aContent );
       
   371                 break;
       
   372                 }
       
   373 
       
   374             default:
       
   375                 {
       
   376                 User::Leave( KErrNotFound );
       
   377                 break;
       
   378                 }
       
   379             };
       
   380         }
       
   381     else
       
   382         {
       
   383         User::Leave( KErrNotFound );    
       
   384         }    
       
   385     
       
   386     }
       
   387 
       
   388 // ----------------------------------------------------------------------------
       
   389 // CAiNaviPaneRenderer::FocusObtainedL()
       
   390 //
       
   391 // ----------------------------------------------------------------------------
       
   392 //
       
   393 void CAiNaviPaneRenderer::FocusObtainedL()
       
   394     {
       
   395     if( !iStatusPanel.IsKeyLockEnabled() )
       
   396         {
       
   397         iAnimator->AnimateL();
       
   398         }
       
   399     iFocusObtained = ETrue;    
       
   400     }
       
   401 
       
   402 // ----------------------------------------------------------------------------
       
   403 // CAiNaviPaneRenderer::FocusLostL()
       
   404 //
       
   405 // ----------------------------------------------------------------------------
       
   406 //
       
   407 void CAiNaviPaneRenderer::FocusLostL()
       
   408     {
       
   409     iAnimator->CancelAnimationL();
       
   410     iFocusObtained = EFalse;
       
   411     iCommitted = EFalse;
       
   412     }
       
   413 
       
   414 // ----------------------------------------------------------------------------
       
   415 // CAiNaviPaneRenderer::KeylockDisabledL()
       
   416 //
       
   417 // ----------------------------------------------------------------------------
       
   418 //
       
   419 void CAiNaviPaneRenderer::KeylockDisabledL()
       
   420     {
       
   421     iAnimator->AnimateL();
       
   422     }
       
   423  
       
   424 // ----------------------------------------------------------------------------
       
   425 // CAiNaviPaneRenderer::KeylockEnabledL()
       
   426 //
       
   427 // ----------------------------------------------------------------------------
       
   428 //    
       
   429 void CAiNaviPaneRenderer::KeylockEnabledL()
       
   430     {
       
   431     iAnimator->CancelAnimationL();
       
   432     }
       
   433     
       
   434 // ----------------------------------------------------------------------------
       
   435 // CAiNaviPaneRenderer::TransactionCommittedL()
       
   436 //
       
   437 // ----------------------------------------------------------------------------
       
   438 //
       
   439 void CAiNaviPaneRenderer::TransactionCommittedL()
       
   440     {
       
   441     if( iIsChanged )
       
   442         {
       
   443         if( iFocusObtained && !iCommitted && !iStatusPanel.IsKeyLockEnabled() )
       
   444             {
       
   445             iAnimator->AnimateL();
       
   446             iCommitted = ETrue;
       
   447             }
       
   448         iIsChanged = EFalse;
       
   449         }
       
   450     }
       
   451     
       
   452 // ----------------------------------------------------------------------------
       
   453 // CAiNaviPaneRenderer::AnimationCompleteL()
       
   454 //
       
   455 // ----------------------------------------------------------------------------
       
   456 //
       
   457 void CAiNaviPaneRenderer::AnimationCompleteL()
       
   458     {
       
   459     // Navi pane animation is now completed -> show original text
       
   460     HBufC* newText = NULL;
       
   461 
       
   462     if ( iProfileText->Length() > 0 )
       
   463         {
       
   464         newText = ConstructProfileTextLC();
       
   465         }
       
   466     else
       
   467         {
       
   468         return;
       
   469         }
       
   470 
       
   471     iStatusPanel.SetNaviPaneTextL( *newText );
       
   472     iStatusPanel.RenderNaviPaneL();
       
   473     
       
   474     CleanupStack::PopAndDestroy( newText );
       
   475     }
       
   476 
       
   477 // End of file