photosgallery/viewframework/dataprovider/src/glxbinding.cpp
branchRCL_3
changeset 60 5b3385a43d68
equal deleted inserted replaced
59:8e5f6eea9c9f 60:5b3385a43d68
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    bindings required to populate the visual item
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxbinding.h"                 // The binding is created by the binding set factory.
       
    22 #include "glxmuliconprovider.h"         // Icon details 
       
    23 #include <StringLoader.h>               // Class provides methods to load and format resource strings
       
    24 #include <mul/mulvisualitem.h>          // Client need to use this class to add data in data model
       
    25 #include <mul/imulwidget.h>
       
    26 #include <glxthumbnailattributeinfo.h>  // Thumbnail attribute content ID
       
    27 #include <mpxcollectionpath.h>          // Encapsulates a 'bookmark' to a specific collection entry
       
    28 #include <glxlog.h>                     // Logging
       
    29 #include <glxtracer.h>
       
    30 #include "glxcommandbindingutility.h"   // collect binding handling here
       
    31 #include "glxmulthumbnailvarianttype.h"
       
    32 #include "mglxbindingobserver.h"        // Notifies that binding has changed
       
    33 #include "glxustringconverter.h"        // converts the symbian types to UString type
       
    34 #include "glxattributerequirement.h"    // class will set the required attribute to the medialist
       
    35 #include "glxuiutility.h"
       
    36 #include "glxdetailsboundcommand.h"     // Handles user commands
       
    37 
       
    38 using namespace Alf;
       
    39 
       
    40 // ----------------------------------------------------------------------------
       
    41 // Sets the attribute to the visual item
       
    42 // ----------------------------------------------------------------------------
       
    43 //
       
    44 static void SetAttributeT( Alf::MulVisualItem& aItem,  const Alf::mulvisualitem::TVisualAttribute& aTag/*const UString& aTag*/, 
       
    45         std::auto_ptr<MulVariantType> aValue )
       
    46     {
       
    47     TRACER("SetAttributeT");
       
    48     aItem.SetAttribute( aTag, aValue.get() );
       
    49     aValue.release();
       
    50     }
       
    51     
       
    52 // ----------------------------------------------------------------------------
       
    53 // Destructor
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 CGlxBinding::~CGlxBinding()
       
    57 	{
       
    58 	
       
    59 	}
       
    60 	
       
    61 // ----------------------------------------------------------------------------
       
    62 // Checks whether the attributes are relevant, returns EFalse always
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 TBool CGlxBinding::HasRelevantAttributes( 
       
    66         const RArray< TMPXAttribute >& /*aAttributes*/  ) const
       
    67 	{
       
    68 	TRACER("CGlxBinding::HasRelevantAttributes");
       
    69 	return EFalse;
       
    70 	}
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // Notification whether any updation is required for the focus changed
       
    74 // ----------------------------------------------------------------------------
       
    75 //
       
    76 CGlxBinding::TResponse CGlxBinding::HandleFocusChanged( TBool /*aIsGained*/ )
       
    77 	{
       
    78 	TRACER("CGlxBinding::HandleFocusChanged");
       
    79 	return ENoUpdateNeeded;
       
    80 	}
       
    81 void  CGlxBinding::HandleItemChangedL(const CMPXCollectionPath& /*aPath*/ )
       
    82     {
       
    83     
       
    84     }
       
    85 	    
       
    86 // ----------------------------------------------------------------------------
       
    87 // Set the binding observer 
       
    88 // ----------------------------------------------------------------------------
       
    89 //
       
    90 void CGlxBinding::SetObserver( MGlxBindingObserver& aObserver )
       
    91 	{
       
    92 	TRACER("CGlxBinding::SetObserver");
       
    93 	iObserver = &aObserver;
       
    94 	}
       
    95 
       
    96 // ----------------------------------------------------------------------------
       
    97 // Initiates the update process when the binding changed
       
    98 // ----------------------------------------------------------------------------
       
    99 //
       
   100 void CGlxBinding::Update()
       
   101 	{
       
   102 	TRACER("CGlxBinding::Update");
       
   103 	__ASSERT_DEBUG( iObserver, User::Invariant() );
       
   104 	iObserver->HandleBindingChanged( *this ); 
       
   105 	}
       
   106 
       
   107 // ----------------------------------------------------------------------------
       
   108 // AddRequestL
       
   109 // ----------------------------------------------------------------------------
       
   110 //
       
   111  void CGlxBinding::AddRequestL( CGlxAttributeRequirements&
       
   112     /*aAttributeRequirement*/, TSize /*aSize*/ )
       
   113     {
       
   114     
       
   115     }
       
   116 
       
   117 // ----------------------------------------------------------------------------
       
   118 // Template Binding
       
   119 //-----------------------------------------------------------------------------	
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // Destructor
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 CGlxTemplateBinding::~CGlxTemplateBinding()  
       
   126     {
       
   127     
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // Two phase constructor
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 CGlxTemplateBinding* CGlxTemplateBinding::NewL(
       
   135     Alf::mulwidget::TLogicalTemplate aTemplate, 
       
   136 	Alf::mulwidget::TLogicalTemplate aTemplateWhenFocused)
       
   137     {
       
   138     TRACER("CGlxTemplateBinding::NewL");
       
   139     CGlxTemplateBinding* self = CGlxTemplateBinding::NewLC( aTemplate, aTemplateWhenFocused );
       
   140     CleanupStack::Pop( self );
       
   141     return self;
       
   142     }
       
   143 
       
   144 
       
   145 // ----------------------------------------------------------------------------
       
   146 // Two phase constructor
       
   147 // ----------------------------------------------------------------------------
       
   148 //
       
   149 CGlxTemplateBinding* CGlxTemplateBinding::NewLC(
       
   150     Alf::mulwidget::TLogicalTemplate aTemplate, 
       
   151 	Alf::mulwidget::TLogicalTemplate aTemplateWhenFocused)
       
   152     {
       
   153     TRACER("CGlxTemplateBinding::NewLC");
       
   154     CGlxTemplateBinding* self = new ( ELeave ) CGlxTemplateBinding();
       
   155     CleanupStack::PushL( self );
       
   156     self->iTemplate = aTemplate;
       
   157     self->iFocusedTemplate = aTemplateWhenFocused;
       
   158     return self;
       
   159     }
       
   160   
       
   161 // ----------------------------------------------------------------------------
       
   162 // PopulateT
       
   163 // ----------------------------------------------------------------------------
       
   164 //
       
   165 void CGlxTemplateBinding::PopulateT( Alf::MulVisualItem& aItem, 
       
   166 	const TGlxMedia& /*aMedia*/, TBool aIsFocused, TInt /*aTextureId*/ ) const
       
   167     {
       
   168     TRACER("CGlxTemplateBinding::PopulateT");
       
   169     // need to get the MUL field for the editable template from Akash
       
   170     
       
   171     aItem.SetAttribute(  Alf::mulvisualitem::KAttributeTemplate , 
       
   172         ( aIsFocused && iFocusedTemplate ) ? iFocusedTemplate : iTemplate );
       
   173     
       
   174     }
       
   175   
       
   176 // ----------------------------------------------------------------------------
       
   177 // HandleFocusChanged
       
   178 // ----------------------------------------------------------------------------
       
   179 //            
       
   180 CGlxBinding::TResponse CGlxTemplateBinding::HandleFocusChanged( TBool /*aIsGained*/ )
       
   181     {
       
   182     TRACER("CGlxTemplateBinding::HandleFocusChanged");
       
   183     //Need further implementation
       
   184     return iFocusedTemplate ? EUpdateRequested: ENoUpdateNeeded;
       
   185     }
       
   186     
       
   187 void CGlxTemplateBinding::HandleItemChangedL(const CMPXCollectionPath& /*aPath*/ )
       
   188     {
       
   189     
       
   190     }
       
   191     
       
   192 // ----------------------------------------------------------------------------
       
   193 // Single Tag Binding
       
   194 //-----------------------------------------------------------------------------	
       
   195 // ----------------------------------------------------------------------------
       
   196 // Constructor
       
   197 // ----------------------------------------------------------------------------
       
   198 //
       
   199 CGlxSingleTagBinding::CGlxSingleTagBinding()
       
   200 	{
       
   201 	
       
   202 	}
       
   203 // ----------------------------------------------------------------------------
       
   204 // Destructor
       
   205 // ----------------------------------------------------------------------------
       
   206 //
       
   207 CGlxSingleTagBinding::~CGlxSingleTagBinding()
       
   208     {
       
   209     TRACER("CGlxSingleTagBinding::~CGlxSingleTagBinding");
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // Two phase construction
       
   214 // ----------------------------------------------------------------------------
       
   215 //
       
   216 void CGlxSingleTagBinding::BaseConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ )
       
   217     {
       
   218     TRACER("CGlxSingleTagBinding::BaseConstructL");
       
   219     iMulTag = aMulTag ;
       
   220     }
       
   221 
       
   222 // ----------------------------------------------------------------------------
       
   223 // Returns the MUL field
       
   224 // ----------------------------------------------------------------------------
       
   225 //
       
   226 Alf::mulvisualitem::TVisualAttribute CGlxSingleTagBinding::MulTag() const
       
   227     {
       
   228     TRACER("CGlxSingleTagBinding::MulTag");
       
   229     return iMulTag;
       
   230     }
       
   231 
       
   232 
       
   233 // ----------------------------------------------------------------------------
       
   234 // String Binding
       
   235 //-----------------------------------------------------------------------------
       
   236 
       
   237 // ----------------------------------------------------------------------------
       
   238 // Two phase construction
       
   239 // ----------------------------------------------------------------------------
       
   240 //
       
   241 CGlxStringBinding* CGlxStringBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   242         TInt aStringId )
       
   243 	{
       
   244 	TRACER("CGlxStringBinding::NewL");
       
   245 	CGlxStringBinding* self = CGlxStringBinding::NewLC( aMulTag, aStringId );
       
   246 	CleanupStack::Pop(self);
       
   247 	return self;
       
   248 	}
       
   249 
       
   250 // ----------------------------------------------------------------------------
       
   251 // Two phase construction
       
   252 // ----------------------------------------------------------------------------
       
   253 //
       
   254 CGlxStringBinding* CGlxStringBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   255         TInt aStringId  )
       
   256     {
       
   257     TRACER("CGlxStringBinding::NewLC");
       
   258     CGlxStringBinding* self = new ( ELeave ) CGlxStringBinding();
       
   259     CleanupStack::PushL( self );
       
   260     self->ConstructL( aMulTag, aStringId );
       
   261     return self;
       
   262     }
       
   263 
       
   264 // ----------------------------------------------------------------------------
       
   265 // Two phase construction
       
   266 // ----------------------------------------------------------------------------
       
   267 //
       
   268 CGlxStringBinding* CGlxStringBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   269         const char* const aString )
       
   270     {
       
   271     TRACER("CGlxStringBinding::NewL");
       
   272     CGlxStringBinding* self = CGlxStringBinding::NewLC( aMulTag, aString );
       
   273     CleanupStack::Pop( self );
       
   274     return self;
       
   275     }
       
   276 // ----------------------------------------------------------------------------
       
   277 // Two phase construction
       
   278 // ----------------------------------------------------------------------------
       
   279 //
       
   280 CGlxStringBinding* CGlxStringBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   281         const char* const aString )
       
   282     {
       
   283     TRACER("CGlxStringBinding::NewLC");
       
   284     CGlxStringBinding* self = new ( ELeave ) CGlxStringBinding();
       
   285     CleanupStack::PushL( self );
       
   286     self->ConstructL( aMulTag, aString );
       
   287     return self;
       
   288     }
       
   289     
       
   290 // ----------------------------------------------------------------------------
       
   291 // Constructor
       
   292 // ----------------------------------------------------------------------------
       
   293 //   
       
   294 CGlxStringBinding::CGlxStringBinding()
       
   295     {
       
   296     
       
   297     }
       
   298     
       
   299 // ----------------------------------------------------------------------------
       
   300 // Destructor
       
   301 // ----------------------------------------------------------------------------
       
   302 //
       
   303 CGlxStringBinding::~CGlxStringBinding()
       
   304     {
       
   305     TRACER("CGlxStringBinding::~CGlxStringBinding");
       
   306     delete iStringBuffer;
       
   307     }
       
   308 
       
   309 // ----------------------------------------------------------------------------
       
   310 //  Two phase construction
       
   311 // ----------------------------------------------------------------------------
       
   312 //    
       
   313 void CGlxStringBinding::ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   314         TInt aStringId )
       
   315 	{
       
   316 	TRACER("CGlxStringBinding::ConstructL");
       
   317 	BaseConstructL( aMulTag );
       
   318     iStringBuffer = StringLoader::LoadL( aStringId );
       
   319 	}
       
   320 
       
   321 // ----------------------------------------------------------------------------
       
   322 // Two phase construction
       
   323 // ----------------------------------------------------------------------------
       
   324 //
       
   325 void CGlxStringBinding::ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/,
       
   326         const char* const /*aString*/ )
       
   327 	{
       
   328 	TRACER("CGlxStringBinding::ConstructL");
       
   329 	BaseConstructL( aMulTag );
       
   330 	}
       
   331 	
       
   332 // ----------------------------------------------------------------------------
       
   333 // populate visual item
       
   334 // ----------------------------------------------------------------------------
       
   335 //
       
   336 void CGlxStringBinding::PopulateT( MulVisualItem& aItem, const TGlxMedia& /*aMedia*/,
       
   337         TBool /*aIsFocused*/, TInt /*aTextureId*/ ) const
       
   338     {
       
   339     TRACER("CGlxStringBinding::PopulateT");
       
   340     aItem.SetAttribute( MulTag(), *iStringBuffer );
       
   341     }
       
   342 	
       
   343 	
       
   344 // ----------------------------------------------------------------------------
       
   345 // MPX attribute Binding
       
   346 //-----------------------------------------------------------------------------
       
   347 
       
   348 // ----------------------------------------------------------------------------
       
   349 // Two phase construction
       
   350 // ----------------------------------------------------------------------------
       
   351 //
       
   352 CGlxMpxAttributeBinding* CGlxMpxAttributeBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const 
       
   353     aMulTag*/, const TMPXAttribute& aAttribute, TInt aFormatStringId )
       
   354     {
       
   355     TRACER("CGlxMpxAttributeBinding::NewL");
       
   356     CGlxMpxAttributeBinding* self = CGlxMpxAttributeBinding::NewLC
       
   357         ( aMulTag, aAttribute, aFormatStringId );
       
   358     CleanupStack::Pop( self );
       
   359     return self;
       
   360     }
       
   361     
       
   362 // ----------------------------------------------------------------------------
       
   363 // Two phase construction
       
   364 // ----------------------------------------------------------------------------
       
   365 //
       
   366 CGlxMpxAttributeBinding* CGlxMpxAttributeBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   367         const TMPXAttribute& aAttribute, TInt aFormatStringId )
       
   368     {
       
   369     TRACER("CGlxMpxAttributeBinding::NewLC");
       
   370     CGlxMpxAttributeBinding* self = new ( ELeave ) CGlxMpxAttributeBinding( 
       
   371         aAttribute, aFormatStringId);
       
   372     CleanupStack::PushL( self );
       
   373     self->ConstructL( aMulTag );
       
   374     return self;
       
   375     }
       
   376 
       
   377 // ----------------------------------------------------------------------------
       
   378 // Two phase construction
       
   379 // ----------------------------------------------------------------------------
       
   380 //    
       
   381 void CGlxMpxAttributeBinding::ConstructL(const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ )
       
   382     {
       
   383     TRACER("CGlxMpxAttributeBinding::ConstructL");
       
   384     BaseConstructL( aMulTag );
       
   385     }
       
   386     
       
   387 // ----------------------------------------------------------------------------
       
   388 // Constructor
       
   389 // ----------------------------------------------------------------------------
       
   390 //
       
   391 CGlxMpxAttributeBinding::CGlxMpxAttributeBinding( const TMPXAttribute&
       
   392      aAttribute, TInt aFormatStringId ) : iAttribute( aAttribute ),
       
   393      iFormatStringId( aFormatStringId )
       
   394     {
       
   395     }
       
   396 
       
   397 // ----------------------------------------------------------------------------
       
   398 // populate visual item
       
   399 // ----------------------------------------------------------------------------
       
   400 //
       
   401 void CGlxMpxAttributeBinding::PopulateT( MulVisualItem& aItem/**/, const 
       
   402     TGlxMedia& aMedia, TBool /*aIsFocused*/, TInt /*aTextureId*/ ) const
       
   403     {
       
   404     TRACER("CGlxMpxAttributeBinding::PopulateT");
       
   405     //T is used for throws as per C++ standard.Hence used instead of "L"
       
   406     //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions.
       
   407     CGlxUStringConverter* stringConverter = CGlxUStringConverter::NewL();
       
   408     CleanupStack::PushL(stringConverter );
       
   409     HBufC* string = NULL;
       
   410     stringConverter->AsStringL( aMedia, iAttribute, iFormatStringId, string );  
       
   411     if ( string )
       
   412         {
       
   413         aItem.SetAttribute( MulTag(), *string );
       
   414         delete string;
       
   415         string = NULL;
       
   416         }
       
   417     CleanupStack::PopAndDestroy(stringConverter );
       
   418     }
       
   419 
       
   420 // ----------------------------------------------------------------------------
       
   421 // checks whether the attributes are relevant, returns EFalse always
       
   422 // ----------------------------------------------------------------------------
       
   423 //
       
   424 TBool CGlxMpxAttributeBinding::HasRelevantAttributes( 
       
   425         const RArray< TMPXAttribute >& aAttributes ) const
       
   426     {
       
   427     TRACER("CGlxMpxAttributeBinding::HasRelevantAttributes");
       
   428     // only the member attribute is relevant; check if it is in the list
       
   429     TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match );
       
   430     return ( KErrNotFound != aAttributes.Find( iAttribute, match ) );
       
   431     }
       
   432 	
       
   433 // ----------------------------------------------------------------------------
       
   434 // checks whether the focus has changed, returns the response status 
       
   435 // ----------------------------------------------------------------------------
       
   436 //	
       
   437 CGlxBinding::TResponse CGlxMpxAttributeBinding::HandleFocusChanged( 
       
   438         TBool aIsGained )
       
   439     {
       
   440     TRACER("CGlxMpxAttributeBinding::HandleFocusChanged");
       
   441     //Need further implementation
       
   442     return aIsGained ? EUpdateRequested : ENoUpdateNeeded ;
       
   443     }
       
   444     
       
   445 void CGlxMpxAttributeBinding::HandleItemChangedL(const CMPXCollectionPath& /*aPath*/ )
       
   446     {
       
   447     
       
   448     }
       
   449 // ----------------------------------------------------------------------------
       
   450 // sends the attribute that is to be set to the medialist
       
   451 // ----------------------------------------------------------------------------
       
   452 //
       
   453  void CGlxMpxAttributeBinding::AddRequestL( CGlxAttributeRequirements&  
       
   454     aAttributeRequirement,TSize /*aSize*/ )
       
   455     {
       
   456     TRACER("CGlxMpxAttributeBinding::AddRequestL");
       
   457     aAttributeRequirement.AddAttributeL(iAttribute);
       
   458     }
       
   459  
       
   460 // ----------------------------------------------------------------------------
       
   461 // Thumbnail Binding
       
   462 //-----------------------------------------------------------------------------
       
   463 
       
   464 // ----------------------------------------------------------------------------
       
   465 // Two phase construction
       
   466 // ----------------------------------------------------------------------------
       
   467 //
       
   468 CGlxThumbnailBinding* CGlxThumbnailBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, 
       
   469 	const TSize& aSize )
       
   470     {
       
   471     TRACER("CGlxThumbnailBinding::NewL");
       
   472     CGlxThumbnailBinding* self = CGlxThumbnailBinding::NewLC( aMulTag, aSize );
       
   473     CleanupStack::Pop( self );
       
   474     return self;
       
   475     }
       
   476     
       
   477 // ----------------------------------------------------------------------------
       
   478 // Two phase construction
       
   479 // ----------------------------------------------------------------------------
       
   480 //
       
   481 CGlxThumbnailBinding* CGlxThumbnailBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, 
       
   482 	const TSize& aSize )
       
   483     {
       
   484     TRACER("CGlxThumbnailBinding::NewLC");
       
   485     CGlxThumbnailBinding* self = new ( ELeave ) CGlxThumbnailBinding( aSize );
       
   486     CleanupStack::PushL( self );
       
   487     self->BaseConstructL( aMulTag );
       
   488     return self;
       
   489     }
       
   490     
       
   491 // ----------------------------------------------------------------------------
       
   492 // Constructor
       
   493 // ----------------------------------------------------------------------------
       
   494 //
       
   495 CGlxThumbnailBinding::CGlxThumbnailBinding( const TSize& aSize ) : 
       
   496     iThumbnailSize( aSize )
       
   497     {
       
   498     }
       
   499     
       
   500 // ----------------------------------------------------------------------------
       
   501 // Destructor
       
   502 // ----------------------------------------------------------------------------
       
   503 //
       
   504 CGlxThumbnailBinding::~CGlxThumbnailBinding()
       
   505     {
       
   506     }
       
   507  
       
   508 // ----------------------------------------------------------------------------
       
   509 // populate visual item
       
   510 // ----------------------------------------------------------------------------
       
   511 //
       
   512 void CGlxThumbnailBinding::PopulateT( MulVisualItem& aItem, const TGlxMedia& 
       
   513     aMedia, TBool aIsFocused, TInt aTextureId ) const
       
   514     {
       
   515     TRACER("CGlxThumbnailBinding::PopulateT");
       
   516     //T is used for throws as per C++ standard.Hence used instead of "L"
       
   517     //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions.
       
   518     SetAttributeT( aItem, MulTag(), 
       
   519         std::auto_ptr< GlxThumbnailVariantType >( 
       
   520             GlxThumbnailVariantType::NewL( aMedia, iThumbnailSize, 
       
   521         aIsFocused, aTextureId ) ) );
       
   522         //@todo
       
   523     }
       
   524 
       
   525 // ----------------------------------------------------------------------------
       
   526 // checks whether the attributes are relevant, returns EFalse always
       
   527 // ----------------------------------------------------------------------------
       
   528 //
       
   529 TBool CGlxThumbnailBinding::HasRelevantAttributes( 
       
   530         const RArray< TMPXAttribute >& aAttributes  ) const
       
   531     {
       
   532     
       
   533     TRACER("CGlxThumbnailBinding::HasRelevantAttributes");
       
   534     TMPXAttribute tnAttribQuality(KGlxMediaIdThumbnail, 
       
   535         GlxFullThumbnailAttributeId( ETrue,  iThumbnailSize.iWidth, 
       
   536         iThumbnailSize.iHeight ) );
       
   537                                                      
       
   538     TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match );
       
   539 	if (KErrNotFound != aAttributes.Find( tnAttribQuality, match ) )
       
   540 		{
       
   541 	    GLX_DEBUG1("CGlxThumbnailBinding::HasRelevantAttributes (tnAttribQuality) - ETrue");
       
   542 		return ETrue;
       
   543 		}
       
   544 	else
       
   545 		{
       
   546 		TMPXAttribute tnAttribSpeed(KGlxMediaIdThumbnail, 
       
   547         GlxFullThumbnailAttributeId( EFalse,  iThumbnailSize.iWidth, 
       
   548         iThumbnailSize.iHeight ) );
       
   549                                                      
       
   550 		if ( KErrNotFound != aAttributes.Find( tnAttribSpeed, match ) )
       
   551             {
       
   552             GLX_DEBUG1("CGlxThumbnailBinding::HasRelevantAttributes (tnAttribSpeed) - ETrue");
       
   553             return ETrue;
       
   554             }
       
   555 		}
       
   556     GLX_DEBUG1("CGlxThumbnailBinding::HasRelevantAttributes - EFalse");
       
   557 	return EFalse;
       
   558     }
       
   559 
       
   560 // ----------------------------------------------------------------------------
       
   561 // invokes the necessary api that sets the thumbnail attribute to the medialist
       
   562 // ----------------------------------------------------------------------------
       
   563 //
       
   564 void CGlxThumbnailBinding::AddRequestL( CGlxAttributeRequirements& 
       
   565     aAttributeRequirement,TSize /*aSize*/ )
       
   566     {
       
   567     TRACER("CGlxThumbnailBinding::AddRequestL");
       
   568     aAttributeRequirement.AddThumbnailL( iThumbnailSize );
       
   569     }
       
   570     
       
   571 
       
   572 // ----------------------------------------------------------------------------
       
   573 // sends response whether update required or not depending on the focus gained
       
   574 // ----------------------------------------------------------------------------
       
   575 //    
       
   576 CGlxBinding::TResponse CGlxThumbnailBinding::HandleFocusChanged( TBool aIsGained )
       
   577     {
       
   578     TRACER("CGlxThumbnailBinding::HandleFocusChanged");
       
   579     if(aIsGained)
       
   580         {
       
   581         
       
   582         return EUpdateRequested;
       
   583         }
       
   584         
       
   585     return ENoUpdateNeeded;
       
   586     }
       
   587 // ----------------------------------------------------------------------------
       
   588 // FullScreenThumbnail Binding
       
   589 //-----------------------------------------------------------------------------
       
   590 
       
   591 // ----------------------------------------------------------------------------
       
   592 // Two phase construction
       
   593 // ----------------------------------------------------------------------------
       
   594 //
       
   595 CGlxFullScreenThumbnailBinding* CGlxFullScreenThumbnailBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ )
       
   596     {
       
   597     TRACER("CGlxFullScreenThumbnailBinding::NewL");
       
   598     CGlxFullScreenThumbnailBinding* self = CGlxFullScreenThumbnailBinding::NewLC( aMulTag );
       
   599     CleanupStack::Pop( self );
       
   600     return self;
       
   601     }
       
   602     
       
   603 // ----------------------------------------------------------------------------
       
   604 // Two phase construction
       
   605 // ----------------------------------------------------------------------------
       
   606 //
       
   607 CGlxFullScreenThumbnailBinding* CGlxFullScreenThumbnailBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/
       
   608 	)
       
   609     {
       
   610     TRACER("CGlxFullScreenThumbnailBinding::NewLC");
       
   611     CGlxFullScreenThumbnailBinding* self = new ( ELeave ) CGlxFullScreenThumbnailBinding();
       
   612     CleanupStack::PushL( self );
       
   613     self->BaseConstructL( aMulTag );
       
   614     return self;
       
   615     }
       
   616     
       
   617 // ----------------------------------------------------------------------------
       
   618 // Constructor
       
   619 // ----------------------------------------------------------------------------
       
   620 //
       
   621 CGlxFullScreenThumbnailBinding::CGlxFullScreenThumbnailBinding( ) 
       
   622     {
       
   623     }
       
   624     
       
   625 // ----------------------------------------------------------------------------
       
   626 // Destructor
       
   627 // ----------------------------------------------------------------------------
       
   628 //
       
   629 CGlxFullScreenThumbnailBinding::~CGlxFullScreenThumbnailBinding()
       
   630     {
       
   631     }
       
   632  
       
   633 // ----------------------------------------------------------------------------
       
   634 // populate visual item
       
   635 // ----------------------------------------------------------------------------
       
   636 //
       
   637 void CGlxFullScreenThumbnailBinding::PopulateT( MulVisualItem& aItem, const TGlxMedia& 
       
   638     aMedia, TBool aIsFocused, TInt aTextureId ) const
       
   639     {
       
   640     TRACER("CGlxFullScreenThumbnailBinding::PopulateT");
       
   641     //T is used for throws as per C++ standard.Hence used instead of "L"
       
   642     //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions.
       
   643     SetAttributeT( aItem, MulTag(), 
       
   644         std::auto_ptr< GlxThumbnailVariantType >( 
       
   645         GlxThumbnailVariantType::NewL( aMedia, iFullScreenThumbnailSize, 
       
   646         aIsFocused, aTextureId ) ) );
       
   647         
       
   648     }
       
   649 
       
   650 // ----------------------------------------------------------------------------
       
   651 // checks whether the attributes are relevant, returns EFalse always
       
   652 // ----------------------------------------------------------------------------
       
   653 //
       
   654 TBool CGlxFullScreenThumbnailBinding::HasRelevantAttributes( 
       
   655         const RArray< TMPXAttribute >& aAttributes  ) const
       
   656     {
       
   657     
       
   658     TRACER("CGlxFullScreenThumbnailBinding::HasRelevantAttributes");
       
   659     TMPXAttribute tnAttribQuality(KGlxMediaIdThumbnail, 
       
   660         GlxFullThumbnailAttributeId( ETrue,  iFullScreenThumbnailSize.iWidth, 
       
   661         iFullScreenThumbnailSize.iHeight ) );
       
   662                                                      
       
   663     TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match );
       
   664     if ( KErrNotFound != aAttributes.Find( tnAttribQuality, match ) )
       
   665         {
       
   666         GLX_DEBUG1("CGlxFullScreenThumbnailBinding::HasRelevantAttributes (tnAttribQuality) - ETrue");
       
   667         return ETrue;        
       
   668         }
       
   669     else
       
   670         {      
       
   671         TMPXAttribute tnAttribSpeed(KGlxMediaIdThumbnail, 
       
   672             GlxFullThumbnailAttributeId( EFalse,  iFullScreenThumbnailSize.iWidth, 
       
   673             iFullScreenThumbnailSize.iHeight ) );
       
   674         if ( KErrNotFound != aAttributes.Find( tnAttribSpeed, match ) )
       
   675             {
       
   676             GLX_DEBUG1("CGlxFullScreenThumbnailBinding::HasRelevantAttributes (tnAttribSpeed) - ETrue");
       
   677             return ETrue;
       
   678             }
       
   679         }
       
   680 
       
   681     GLX_DEBUG1("CGlxFullScreenThumbnailBinding::HasRelevantAttributes - EFalse");
       
   682     return EFalse;   
       
   683     }
       
   684 
       
   685 // ----------------------------------------------------------------------------
       
   686 // invokes the necessary api that sets the thumbnail attribute to the medialist
       
   687 // ----------------------------------------------------------------------------
       
   688 //
       
   689 void CGlxFullScreenThumbnailBinding::AddRequestL( CGlxAttributeRequirements& aAttributeRequirement,TSize aSize)
       
   690     {
       
   691     TRACER("CGlxFullScreenThumbnailBinding::AddRequestL");
       
   692     iFullScreenThumbnailSize = aSize;
       
   693     aAttributeRequirement.AddThumbnailL( iFullScreenThumbnailSize );
       
   694 	CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL();
       
   695 	CleanupStack::PushL( uiUtility );
       
   696 	aAttributeRequirement.AddThumbnailL( uiUtility->GetGridIconSize() );
       
   697 	uiUtility->Close();
       
   698 	CleanupStack::Pop( uiUtility );
       
   699     }
       
   700     
       
   701 
       
   702 // ----------------------------------------------------------------------------
       
   703 // sends response whether update required or not depending on the focus gained
       
   704 // ----------------------------------------------------------------------------
       
   705 //    
       
   706 CGlxBinding::TResponse CGlxFullScreenThumbnailBinding::HandleFocusChanged( TBool aIsGained )
       
   707     {
       
   708     TRACER("CGlxFullScreenThumbnailBinding::HandleFocusChanged");
       
   709     if(aIsGained)
       
   710         {
       
   711         
       
   712         return EUpdateRequested;
       
   713         }
       
   714         
       
   715     return ENoUpdateNeeded;
       
   716     }
       
   717     
       
   718 // ----------------------------------------------------------------------------
       
   719 // Icon Binding
       
   720 //-----------------------------------------------------------------------------
       
   721 
       
   722 // ----------------------------------------------------------------------------
       
   723 // Two phase construction
       
   724 // ----------------------------------------------------------------------------
       
   725 //
       
   726 CGlxIconBinding* CGlxIconBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   727      const CGlxMulIconProvider* aMulIcon, const TSize& aSize)
       
   728     {
       
   729     TRACER("CGlxIconBinding::NewL");
       
   730     CGlxIconBinding* self = CGlxIconBinding::NewLC( aMulTag, aMulIcon, aSize );
       
   731     CleanupStack::Pop( self );
       
   732     return self;
       
   733     }
       
   734     
       
   735 // ----------------------------------------------------------------------------
       
   736 // Two phase construction
       
   737 // ----------------------------------------------------------------------------
       
   738 //
       
   739 CGlxIconBinding* CGlxIconBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/,
       
   740      const CGlxMulIconProvider* aMulIcon, const TSize& aSize)
       
   741     {
       
   742     TRACER("CGlxIconBinding::NewLC");
       
   743     CGlxIconBinding* self = new ( ELeave ) CGlxIconBinding( aMulIcon, aSize );
       
   744     CleanupStack::PushL( self );
       
   745     self->BaseConstructL( aMulTag );
       
   746     return self;
       
   747     }
       
   748 
       
   749 // ----------------------------------------------------------------------------
       
   750 // Destructor
       
   751 // ----------------------------------------------------------------------------
       
   752 //
       
   753 CGlxIconBinding::~CGlxIconBinding()
       
   754     {
       
   755     delete iIconProvider;
       
   756     }
       
   757  
       
   758 // ----------------------------------------------------------------------------
       
   759 // Constructor
       
   760 // ----------------------------------------------------------------------------
       
   761 //
       
   762 CGlxIconBinding::CGlxIconBinding( const CGlxMulIconProvider* aIconProvider, 
       
   763        const TSize& aSize ) : iIconProvider( aIconProvider ), iIconSize(aSize)
       
   764     {
       
   765     
       
   766     }
       
   767 
       
   768 // ----------------------------------------------------------------------------
       
   769 // populate visual item
       
   770 // ----------------------------------------------------------------------------
       
   771 //
       
   772 void CGlxIconBinding::PopulateT( MulVisualItem& aItem, 
       
   773            const TGlxMedia& aMedia, TBool /*aIsFocused*/, TInt /*aTextureId*/ ) const
       
   774     {
       
   775     
       
   776     TRACER("CGlxIconBinding::PopulateT");
       
   777     if(iIconProvider)
       
   778     {
       
   779     SetAttributeT( aItem, MulTag(), 
       
   780         std::auto_ptr< GlxIconVariantType >( 
       
   781         GlxIconVariantType::NewL( iIconProvider->IconIdL(aMedia), 
       
   782                 iIconProvider->ResourceFileName(), iIconSize ) ) );	
       
   783     }
       
   784     
       
   785     }
       
   786 
       
   787 // ----------------------------------------------------------------------------
       
   788 // Command Binding
       
   789 //-----------------------------------------------------------------------------
       
   790 
       
   791 // ----------------------------------------------------------------------------
       
   792 // Two phase construction
       
   793 // ----------------------------------------------------------------------------
       
   794 //
       
   795 CGlxCommandBinding* CGlxCommandBinding::NewL( MGlxBoundCommand* aCommand )
       
   796 	{
       
   797 	TRACER("CGlxCommandBinding::NewL");
       
   798 	CGlxCommandBinding* self = CGlxCommandBinding::NewLC( aCommand );
       
   799 	CleanupStack::Pop( self );
       
   800     return self;
       
   801 	}
       
   802 	
       
   803 // ----------------------------------------------------------------------------
       
   804 // Two phase construction
       
   805 // ----------------------------------------------------------------------------
       
   806 //
       
   807 CGlxCommandBinding* CGlxCommandBinding::NewLC( MGlxBoundCommand* aCommand )
       
   808     {
       
   809     TRACER("CGlxCommandBinding::NewLC");
       
   810     __ASSERT_DEBUG( aCommand ,User::Invariant()); 
       
   811     CGlxCommandBinding* self = new ( ELeave ) CGlxCommandBinding();
       
   812     self->iCommand = aCommand; 
       
   813     // cannot pass aCommand since abstract MGlxCommand pointer is a few bytes off
       
   814     // from the concrete derived class pointer
       
   815     CleanupStack::PushL( self );
       
   816     return self;
       
   817     }
       
   818     
       
   819 // ----------------------------------------------------------------------------
       
   820 // Constructor
       
   821 // ----------------------------------------------------------------------------
       
   822 //
       
   823 CGlxCommandBinding::CGlxCommandBinding()
       
   824     {
       
   825     }
       
   826     
       
   827 // ----------------------------------------------------------------------------
       
   828 // Destructor
       
   829 // ----------------------------------------------------------------------------
       
   830 //
       
   831 CGlxCommandBinding::~CGlxCommandBinding()
       
   832     {
       
   833     if(iCommand)
       
   834         {
       
   835         iCommand->Close();
       
   836         }
       
   837     }    
       
   838     
       
   839 // ----------------------------------------------------------------------------
       
   840 // populate visual item
       
   841 // ----------------------------------------------------------------------------
       
   842 //
       
   843 void CGlxCommandBinding::PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& /*aMedia*/,
       
   844         TBool /*aIsFocused*/, TInt /*aTextureId*/ ) const
       
   845     {
       
   846     TRACER("CGlxCommandBinding::PopulateT");
       
   847     GlxCommandBindingUtility::SetT( aItem, *iCommand );
       
   848     }
       
   849