idlehomescreen/nativeuicontroller/src/aititlepanerenderer.cpp
changeset 0 f72a12da539e
child 1 5315654608de
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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 
       
    19 #include <StringLoader.h>
       
    20 #include <AiNativeUi.rsg>
       
    21 #include <gulicon.h>
       
    22 #include "aititlepanerenderer.h"
       
    23 #include "aistatuspanel.h"
       
    24 #include "aipropertyextension.h"
       
    25 #include <aicontentrequest.h>
       
    26 #include "ainativeuiplugins.h"
       
    27 #include "debug.h"
       
    28 
       
    29 using namespace AiNativeUiController;
       
    30 
       
    31 
       
    32 void CAiTitlePaneRenderer::ConstructL()
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 CAiTitlePaneRenderer* CAiTitlePaneRenderer::NewLC( CAiStatusPanel& aStatusPanel )
       
    38     {
       
    39     CAiTitlePaneRenderer* self = new( ELeave ) CAiTitlePaneRenderer( aStatusPanel );
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     return self;
       
    43     }
       
    44 
       
    45 
       
    46 CAiTitlePaneRenderer::~CAiTitlePaneRenderer()
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 CAiTitlePaneRenderer::CAiTitlePaneRenderer( CAiStatusPanel& aStatusPanel )
       
    52 	: iStatusPanel( aStatusPanel )
       
    53     {
       
    54     }
       
    55 
       
    56 
       
    57 
       
    58 
       
    59 void CAiTitlePaneRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
       
    60 										TInt aContent,
       
    61 										const TDesC16& aText,
       
    62 										TInt /*aIndex*/ )
       
    63     {
       
    64     if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid )
       
    65 	    {
       
    66 	    switch( aContent )
       
    67 	        {
       
    68 	        case EAiDeviceStatusContentNetworkIdentity:
       
    69 	            {
       
    70 	            __PRINT(__DBG_FORMAT("XAI: Render title pane - %d, %S"), aContent, &aText );
       
    71 	        	iStatusPanel.SetTitlePaneTextL( aText );
       
    72 	        	// we're publishing text -> set bitmap as invalid
       
    73 	        	iStatusPanel.SetTitlePaneBitmapL( KErrNotFound, KErrNotFound );
       
    74 	            iStatusPanel.RenderTitlePaneL();
       
    75 	        	__PRINTS( "XAI: Render title pane - done");
       
    76 
       
    77 	            break;
       
    78 	            }
       
    79 	        default:
       
    80 	            {
       
    81 	            User::Leave( KErrNotFound );
       
    82 	            break;
       
    83 	            }
       
    84 	        };
       
    85 	    }
       
    86 	else
       
    87 		{
       
    88 		User::Leave( KErrNotFound );
       
    89 		}
       
    90     }
       
    91 
       
    92 void CAiTitlePaneRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
       
    93 										TInt aContent,
       
    94 										const TDesC8& aBuf,
       
    95 										TInt /*aIndex*/ )
       
    96     {
       
    97    	if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid )
       
    98 	   	{
       
    99 	    switch( aContent )
       
   100 	        {
       
   101 	        case EAiDeviceStatusContentNetworkIdentity:
       
   102 	            {
       
   103 	           	__PRINTS( "XAI: Render title pane - oper logo");
       
   104 
       
   105 	            CGulIcon* icon = NULL;
       
   106 	            TPckg<CGulIcon*>( icon ).Copy( aBuf );
       
   107 
       
   108 	            if( icon )
       
   109 	                {
       
   110 	                TInt bitmapHandle = icon->Bitmap() ?
       
   111 	                					icon->Bitmap()->Handle() : KErrNotFound;
       
   112 	                TInt maskHandle = icon->Mask() ?
       
   113 	                					icon->Mask()->Handle() : KErrNotFound;
       
   114 
       
   115 	                // SetTitlePaneBitmapL checks if handle was valid, so no 
       
   116 	                // problem passing KErrNotFound
       
   117 	                iStatusPanel.SetTitlePaneBitmapL( bitmapHandle, maskHandle );
       
   118 	                // We're publishing bitmap -> set text as invalid
       
   119 	                iStatusPanel.SetTitlePaneTextL( KNullDesC );
       
   120 	                iStatusPanel.RenderTitlePaneL();
       
   121 	                 __PRINTS("XAI: Rendering title pane - done");
       
   122 	                }
       
   123 	            break;
       
   124 	            }
       
   125 	        default:
       
   126 	            {
       
   127 	            User::Leave( KErrNotFound );
       
   128 	            break;
       
   129 	            }
       
   130 	        };
       
   131 	   	}
       
   132 	else
       
   133 		{
       
   134 		User::Leave( KErrNotFound );
       
   135 		}
       
   136     }
       
   137 
       
   138 void CAiTitlePaneRenderer::DoPublishL( MAiPropertyExtension& aPlugin, 
       
   139                                     	TInt aContent, 
       
   140                                     	TInt aResource,
       
   141                                     	TInt /*aIndex*/ )
       
   142     {
       
   143     if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid )
       
   144 	    {
       
   145 	    switch( aContent )
       
   146 	        {
       
   147 	        case EAiDeviceStatusContentNetworkIdentity:
       
   148 	            {
       
   149 	            HBufC* text = StringLoader::LoadLC( aResource );      
       
   150 	            iStatusPanel.SetTitlePaneTextL( *text );
       
   151 	        	// We're publishing text -> set bitmap as invalid
       
   152 	        	iStatusPanel.SetTitlePaneBitmapL( KErrNotFound, KErrNotFound );
       
   153 	            iStatusPanel.RenderTitlePaneL();
       
   154 	       
       
   155 	            CleanupStack::PopAndDestroy(text); //text
       
   156 	            break;
       
   157 	            }
       
   158 	        default:
       
   159 	            {
       
   160 	            User::Leave( KErrNotFound );
       
   161 	            break;
       
   162 	            }
       
   163 	        };
       
   164 	    }
       
   165 	else
       
   166 		{
       
   167 		User::Leave( KErrNotFound );
       
   168 		}
       
   169     }
       
   170 
       
   171 
       
   172 void CAiTitlePaneRenderer::DoCleanL( MAiPropertyExtension& aPlugin, TInt aContent )
       
   173 	{
       
   174     __PRINT(__DBG_FORMAT("XAI: Clean title pane - %d"), aContent );
       
   175 	if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid )
       
   176 		{
       
   177 	    switch( aContent )
       
   178 	        {
       
   179 	        case EAiDeviceStatusContentNetworkIdentity:
       
   180 	            {
       
   181 	            // Publish empty text
       
   182 	            iStatusPanel.SetTitlePaneTextL( KNullDesC );
       
   183 	        	iStatusPanel.SetTitlePaneBitmapL( KErrNotFound, KErrNotFound );
       
   184 	            iStatusPanel.RenderTitlePaneL();
       
   185 	            __PRINTS( "XAI: Clean title pane - done");
       
   186 	            break;
       
   187 	            }
       
   188 
       
   189 	        default:
       
   190 	            {
       
   191 				User::Leave( KErrNotFound );
       
   192 	            break;
       
   193 	            }
       
   194 	        };
       
   195 		}
       
   196 	else
       
   197 		{
       
   198 		User::Leave( KErrNotFound );
       
   199 		}
       
   200 	}
       
   201 
       
   202 void CAiTitlePaneRenderer::TransactionCommittedL()
       
   203     {
       
   204     }
       
   205 
       
   206 void CAiTitlePaneRenderer::KeylockEnabledL()
       
   207 	{
       
   208 	iStatusPanel.StopTitlePaneScrollingL();
       
   209 	}
       
   210 
       
   211 void CAiTitlePaneRenderer::FocusObtainedL()
       
   212     {
       
   213     // This scrolls the title pane text only if it has been changed
       
   214     iStatusPanel.RenderTitlePaneL();
       
   215     // Force the scroll just to be safe
       
   216     iStatusPanel.ScrollTitlePaneTextL();
       
   217     }
       
   218 
       
   219 void CAiTitlePaneRenderer::FocusLostL()
       
   220 	{
       
   221 	iStatusPanel.StopTitlePaneScrollingL();
       
   222 	}