idlehomescreen/nativeuicontroller/src/aititlepanerenderer.cpp
branchRCL_3
changeset 34 5456b4e8b3a8
child 35 3321d3e205b6
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:  Handles publishing to title pane.
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <StringLoader.h>
       
    20 #include <AiNativeUi.rsg>
       
    21 #include <gulicon.h>
       
    22 
       
    23 // User includes
       
    24 #include <hscontentpublisher.h>
       
    25 #include <hspublisherinfo.h>
       
    26 
       
    27 #include "aititlepanerenderer.h"
       
    28 #include "aistatuspanel.h"
       
    29 
       
    30 #include <aicontentrequest.h>
       
    31 #include "ainativeuiplugins.h"
       
    32 #include "debug.h"
       
    33 
       
    34 using namespace AiNativeUiController;
       
    35 
       
    36 // ======== MEMBER FUNCTIONS ========
       
    37 // ----------------------------------------------------------------------------
       
    38 // CAiTitlePaneRenderer::ConstructL()
       
    39 //
       
    40 // ----------------------------------------------------------------------------
       
    41 //
       
    42 void CAiTitlePaneRenderer::ConstructL()
       
    43     {
       
    44     }
       
    45 
       
    46 // ----------------------------------------------------------------------------
       
    47 // CAiTitlePaneRenderer::NewLC()
       
    48 //
       
    49 // ----------------------------------------------------------------------------
       
    50 //
       
    51 CAiTitlePaneRenderer* CAiTitlePaneRenderer::NewLC( 
       
    52     CAiStatusPanel& aStatusPanel )
       
    53     {
       
    54     CAiTitlePaneRenderer* self = 
       
    55         new( ELeave ) CAiTitlePaneRenderer( aStatusPanel );
       
    56     
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     return self;
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CAiTitlePaneRenderer::CAiTitlePaneRenderer()
       
    64 //
       
    65 // ----------------------------------------------------------------------------
       
    66 //
       
    67 CAiTitlePaneRenderer::~CAiTitlePaneRenderer()
       
    68     {
       
    69     }
       
    70 
       
    71 // ----------------------------------------------------------------------------
       
    72 // CAiTitlePaneRenderer::CAiTitlePaneRenderer()
       
    73 //
       
    74 // ----------------------------------------------------------------------------
       
    75 //
       
    76 CAiTitlePaneRenderer::CAiTitlePaneRenderer( CAiStatusPanel& aStatusPanel )
       
    77 	: iStatusPanel( aStatusPanel )
       
    78     {
       
    79     }
       
    80 
       
    81 // ----------------------------------------------------------------------------
       
    82 // CAiTitlePaneRenderer::DoPublishL()
       
    83 //
       
    84 // ----------------------------------------------------------------------------
       
    85 //
       
    86 void CAiTitlePaneRenderer::DoPublishL( CHsContentPublisher& aPlugin,
       
    87     TInt aContent, const TDesC16& aText, TInt /*aIndex*/ )
       
    88     {
       
    89     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
    90     
       
    91     if( info.Uid() == KDeviceStatusPluginUid )
       
    92 	    {
       
    93 	    switch( aContent )
       
    94 	        {
       
    95 	        case EAiDeviceStatusContentNetworkIdentity:
       
    96 	            {
       
    97 	            __PRINT(__DBG_FORMAT("XAI: Render title pane - %d, %S"), aContent, &aText );
       
    98 	        	iStatusPanel.SetTitlePaneTextL( aText );
       
    99 	        	// we're publishing text -> set bitmap as invalid
       
   100 	        	iStatusPanel.SetTitlePaneBitmapL( KErrNotFound, KErrNotFound );
       
   101 	            iStatusPanel.RenderTitlePaneL();
       
   102 	        	__PRINTS( "XAI: Render title pane - done");
       
   103 
       
   104 	            break;
       
   105 	            }
       
   106 	        default:
       
   107 	            {
       
   108 	            User::Leave( KErrNotFound );
       
   109 	            break;
       
   110 	            }
       
   111 	        };
       
   112 	    }
       
   113 	else
       
   114 		{
       
   115 		User::Leave( KErrNotFound );
       
   116 		}
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CAiTitlePaneRenderer::DoPublishL()
       
   121 //
       
   122 // ----------------------------------------------------------------------------
       
   123 //
       
   124 void CAiTitlePaneRenderer::DoPublishL( CHsContentPublisher& aPlugin,
       
   125 	TInt aContent, const TDesC8& aBuf, TInt /*aIndex*/ )
       
   126     {
       
   127     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   128     
       
   129    	if( info.Uid() == KDeviceStatusPluginUid )
       
   130 	   	{
       
   131 	    switch( aContent )
       
   132 	        {
       
   133 	        case EAiDeviceStatusContentNetworkIdentity:
       
   134 	            {
       
   135 	           	__PRINTS( "XAI: Render title pane - oper logo");
       
   136 
       
   137 	            CGulIcon* icon = NULL;
       
   138 	            TPckg<CGulIcon*>( icon ).Copy( aBuf );
       
   139 
       
   140 	            if( icon )
       
   141 	                {
       
   142 	                TInt bitmapHandle = icon->Bitmap() ?
       
   143 	                					icon->Bitmap()->Handle() : KErrNotFound;
       
   144 	                TInt maskHandle = icon->Mask() ?
       
   145 	                					icon->Mask()->Handle() : KErrNotFound;
       
   146 
       
   147 	                // SetTitlePaneBitmapL checks if handle was valid, so no 
       
   148 	                // problem passing KErrNotFound
       
   149 	                iStatusPanel.SetTitlePaneBitmapL( bitmapHandle, maskHandle );
       
   150 	                // We're publishing bitmap -> set text as invalid
       
   151 	                iStatusPanel.SetTitlePaneTextL( KNullDesC );
       
   152 	                iStatusPanel.RenderTitlePaneL();
       
   153 	                 __PRINTS("XAI: Rendering title pane - done");
       
   154 	                }
       
   155 	            break;
       
   156 	            }
       
   157 	        default:
       
   158 	            {
       
   159 	            User::Leave( KErrNotFound );
       
   160 	            break;
       
   161 	            }
       
   162 	        };
       
   163 	   	}
       
   164 	else
       
   165 		{
       
   166 		User::Leave( KErrNotFound );
       
   167 		}
       
   168     }
       
   169 
       
   170 // ----------------------------------------------------------------------------
       
   171 // CAiTitlePaneRenderer::DoPublishL()
       
   172 //
       
   173 // ----------------------------------------------------------------------------
       
   174 //
       
   175 void CAiTitlePaneRenderer::DoPublishL( CHsContentPublisher& aPlugin, 
       
   176     TInt aContent, TInt aResource, TInt /*aIndex*/ )
       
   177     {
       
   178     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   179     
       
   180     if( info.Uid() == KDeviceStatusPluginUid )
       
   181 	    {
       
   182 	    switch( aContent )
       
   183 	        {
       
   184 	        case EAiDeviceStatusContentNetworkIdentity:
       
   185 	            {
       
   186 	            HBufC* text = StringLoader::LoadLC( aResource );      
       
   187 	            iStatusPanel.SetTitlePaneTextL( *text );
       
   188 	        	// We're publishing text -> set bitmap as invalid
       
   189 	        	iStatusPanel.SetTitlePaneBitmapL( KErrNotFound, KErrNotFound );
       
   190 	            iStatusPanel.RenderTitlePaneL();
       
   191 	       
       
   192 	            CleanupStack::PopAndDestroy(text); //text
       
   193 	            break;
       
   194 	            }
       
   195 	        default:
       
   196 	            {
       
   197 	            User::Leave( KErrNotFound );
       
   198 	            break;
       
   199 	            }
       
   200 	        };
       
   201 	    }
       
   202 	else
       
   203 		{
       
   204 		User::Leave( KErrNotFound );
       
   205 		}
       
   206     }
       
   207 
       
   208 // ----------------------------------------------------------------------------
       
   209 // CAiTitlePaneRenderer::DoCleanL()
       
   210 //
       
   211 // ----------------------------------------------------------------------------
       
   212 //
       
   213 void CAiTitlePaneRenderer::DoCleanL( CHsContentPublisher& aPlugin, 
       
   214     TInt aContent )
       
   215 	{
       
   216     __PRINT(__DBG_FORMAT("XAI: Clean title pane - %d"), aContent );
       
   217 	
       
   218     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
   219     
       
   220     if( info.Uid() == KDeviceStatusPluginUid )
       
   221 		{
       
   222 	    switch( aContent )
       
   223 	        {
       
   224 	        case EAiDeviceStatusContentNetworkIdentity:
       
   225 	            {
       
   226 	            // Publish empty text
       
   227 	            iStatusPanel.SetTitlePaneTextL( KNullDesC );
       
   228 	        	iStatusPanel.SetTitlePaneBitmapL( KErrNotFound, KErrNotFound );
       
   229 	            iStatusPanel.RenderTitlePaneL();
       
   230 	            __PRINTS( "XAI: Clean title pane - done");
       
   231 	            break;
       
   232 	            }
       
   233 
       
   234 	        default:
       
   235 	            {
       
   236 				User::Leave( KErrNotFound );
       
   237 	            break;
       
   238 	            }
       
   239 	        };
       
   240 		}
       
   241 	else
       
   242 		{
       
   243 		User::Leave( KErrNotFound );
       
   244 		}
       
   245 	}
       
   246 
       
   247 // ----------------------------------------------------------------------------
       
   248 // CAiTitlePaneRenderer::TransactionCommittedL()
       
   249 //
       
   250 // ----------------------------------------------------------------------------
       
   251 //
       
   252 void CAiTitlePaneRenderer::TransactionCommittedL()
       
   253     {
       
   254     }
       
   255 
       
   256 // ----------------------------------------------------------------------------
       
   257 // CAiTitlePaneRenderer::KeylockEnabledL()
       
   258 //
       
   259 // ----------------------------------------------------------------------------
       
   260 //
       
   261 void CAiTitlePaneRenderer::KeylockEnabledL()
       
   262 	{
       
   263 	iStatusPanel.StopTitlePaneScrollingL();
       
   264 	}
       
   265 
       
   266 // ----------------------------------------------------------------------------
       
   267 // CAiTitlePaneRenderer::FocusObtainedL()
       
   268 //
       
   269 // ----------------------------------------------------------------------------
       
   270 //
       
   271 void CAiTitlePaneRenderer::FocusObtainedL()
       
   272     {
       
   273     iStatusPanel.RenderTitlePaneL();
       
   274     }
       
   275 
       
   276 // ----------------------------------------------------------------------------
       
   277 // CAiTitlePaneRenderer::FocusLostL()
       
   278 //
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 void CAiTitlePaneRenderer::FocusLostL()
       
   282 	{
       
   283 	iStatusPanel.StopTitlePaneScrollingL();
       
   284 	}
       
   285 
       
   286 // End of file