photosgallery/contentharvesterplugin/src/glxcontentharvesterplugincaptured.cpp
changeset 0 4e91876724a2
child 1 9ba538e329bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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:    Updates CPS storage for captured collection
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include <mmf/common/mmfcontrollerpluginresolver.h>
       
    21 #include <LiwServiceHandler.h>
       
    22 
       
    23 #include <glxuistd.h>
       
    24 #include <glxicons.mbg>   // Glx Icons
       
    25 #include <glxcollectionplugincamera.hrh>
       
    26 #include <glxthumbnailattributeinfo.h>  // for KGlxMediaIdThumbnail
       
    27 #include <glxattributecontext.h>
       
    28 #include <glxthumbnailcontext.h>
       
    29 #include <glxtracer.h>
       
    30 #include <glxlog.h>
       
    31 #include <mglxmedialist.h>       // for MGlxMediaList
       
    32 #include <glxcollectiongeneraldefs.h>
       
    33 #include <glxgallery.hrh>               // for KGlxGalleryApplicationUid
       
    34 #include <glxmediaid.h>
       
    35 #include <glxerrormanager.h>  
       
    36 
       
    37 #include "glxcontentharvesterplugincaptured.h"
       
    38 #include "glxcontentharvesterplugin.hrh"
       
    39 #include "glxmapconstants.h"
       
    40 
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS ==============================
       
    43 LOCAL_C TInt TimerCallbackL( TAny* aPtr )
       
    44     {
       
    45     TRACER( "CGlxContentHarvesterPluginCaptured::TimerCallbackL" );
       
    46     static_cast<CGlxContentHarvesterPluginCaptured*>(aPtr)->UpdateDataL();
       
    47     return KErrNone;
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // Constructor
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 CGlxContentHarvesterPluginCaptured::CGlxContentHarvesterPluginCaptured( 
       
    55         MLiwInterface* aCPSInterface,
       
    56         MGlxContentHarvesterPlugin *aCHplugin )
       
    57 
       
    58     {
       
    59     TRACER( "CGlxContentHarvesterPluginCaptured::CGlxContentHarvesterPluginCaptured" );
       
    60     iCPSInterface = aCPSInterface;
       
    61     SetCHPlugin(aCHplugin);
       
    62     }
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // Symbian 2nd phase constructor can leave.
       
    66 // ----------------------------------------------------------------------------
       
    67 //
       
    68 void CGlxContentHarvesterPluginCaptured::ConstructL()
       
    69     {
       
    70     TRACER( "CGlxContentHarvesterPluginCaptured::ConstructL" );
       
    71 
       
    72     //Call the base class ConstructL,to create the default thumbnail
       
    73     CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated);
       
    74     
       
    75     iPeriodic = CPeriodic::NewL( CActive::EPriorityLow );
       
    76     iThumbnailContext = CGlxThumbnailContext::NewL(&iThumbnailIterator);
       
    77     
       
    78     //Register/Subscribe with matrix menu for the notifications 
       
    79     GetInterfaceForNotificationL();
       
    80     SetupPublisherL(KItemIndexCaptured);
       
    81     RequestCpsNotificationL(KItemIndexCaptured);
       
    82     HandleStateChangeL(KItemIndexCaptured);
       
    83     }
       
    84 
       
    85 // ----------------------------------------------------------------------------
       
    86 // Two-phased constructor.
       
    87 // ----------------------------------------------------------------------------
       
    88 //
       
    89 CGlxContentHarvesterPluginCaptured* CGlxContentHarvesterPluginCaptured::NewLC( 
       
    90         MLiwInterface* aCPSInterface,                                                                                               
       
    91         MGlxContentHarvesterPlugin *aCHplugin )
       
    92     {
       
    93     TRACER( "CGlxContentHarvesterPluginCaptured::NewL" );
       
    94     CGlxContentHarvesterPluginCaptured* self = new ( ELeave ) CGlxContentHarvesterPluginCaptured( aCPSInterface,aCHplugin );
       
    95     CleanupStack::PushL(self);
       
    96     self->ConstructL();
       
    97     return self;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Destructor
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 CGlxContentHarvesterPluginCaptured::~CGlxContentHarvesterPluginCaptured()
       
   105     {
       
   106     TRACER( "CGlxContentHarvesterPluginCaptured::~CGlxContentHarvesterPluginCaptured" );
       
   107 
       
   108     DestroyMedialist();
       
   109 
       
   110     if ( iPeriodic )
       
   111         {
       
   112         iPeriodic->Cancel();
       
   113         }
       
   114     delete iPeriodic;
       
   115 
       
   116     }
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // CGlxContentHarvesterPluginCaptured::UpdateDataL()
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 void CGlxContentHarvesterPluginCaptured::UpdateDataL() 
       
   123     {
       
   124     TRACER( "CGlxContentHarvesterPluginCaptured::UpdateDataL" );
       
   125     if(iMediaList && iMediaList->Count() && iPreviewItemCount.Count() )
       
   126         {
       
   127         GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::UpdateDataL(),iProgressIndex=%d",iProgressIndex);
       
   128         TInt ret = UpdateItem(iPreviewItemCount[iProgressIndex]);
       
   129         if(ret != KErrNotFound)
       
   130             {
       
   131             //Updates the thumbnail in the collection 
       
   132             UpdateDataInCPSL(ret);
       
   133             }
       
   134         else
       
   135             {
       
   136             UpdateDataInCPSL(GetBitmapHandle());
       
   137             }
       
   138         }
       
   139     else
       
   140         {
       
   141         // Show previous thumbnail until the new thumbnail is
       
   142 		// fecthed.Added this check to avoid flicker
       
   143 		if(iMediaList->Count() == 0)
       
   144 			{
       
   145 			//Don't Show the Thumbnail/Show nothing
       
   146 			GLX_LOG_INFO("CGlxContentHarvesterPluginCaptured::UpdateDataL() --O");
       
   147 			UpdateDataInCPSL(GetBitmapHandle());
       
   148 			}
       
   149         }
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------------------------------
       
   153 // CGlxContentHarvesterPluginCaptured::HandleNotifyL()
       
   154 // ----------------------------------------------------------------------------
       
   155 //
       
   156 TInt CGlxContentHarvesterPluginCaptured::HandleNotifyL(
       
   157         TInt /* aCmdId*/,
       
   158         TInt/* aEventId */,
       
   159         CLiwGenericParamList& /*aEventParamList*/,
       
   160         const CLiwGenericParamList& /*aInParamList*/ )
       
   161     {
       
   162     TRACER( "CGlxContentHarvesterPluginCaptured::HandleNotifyL" );
       
   163 
       
   164     HandleStateChangeL(KItemIndexCaptured);
       
   165     return KErrNone;
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------------------------------
       
   169 // CGlxContentHarvesterPluginCaptured::HandleItemChanged()
       
   170 // ----------------------------------------------------------------------------
       
   171 //
       
   172 void CGlxContentHarvesterPluginCaptured::HandleItemChanged()
       
   173     {
       
   174     TRACER("CGlxContentHarvesterPluginCaptured::HandleItemChanged");
       
   175 
       
   176     iProgressIndex = 0;
       
   177     iPreviewItemCount.Reset();
       
   178 
       
   179     TSize gridIconSize = GetGridIconSize();
       
   180     TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, 
       
   181             GlxFullThumbnailAttributeId( ETrue,  gridIconSize.iWidth, gridIconSize.iHeight ) );
       
   182     if(iMediaList)  
       
   183         {
       
   184         TInt count = iMediaList->Count();
       
   185         GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured:: HandleItemChanged ,count=%d",count);
       
   186 
       
   187         TBool inFocus = IsFocused();
       
   188         for(TInt aItemIndex = 0; aItemIndex < count ; aItemIndex++)
       
   189             {
       
   190             const TGlxMedia& item = iMediaList->Item( aItemIndex );
       
   191             const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute );
       
   192             if (value)
       
   193                 {
       
   194                 iPreviewItemCount.InsertInOrder(aItemIndex);
       
   195                 if(!inFocus)
       
   196                     {
       
   197                     //if the collection is NOT in Focus,retrive only one thumbnail and break
       
   198                     GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::HandleItemChanged,iRange=1,aItemIndex=%d",aItemIndex);
       
   199                     break;
       
   200                     }
       
   201                 else if(iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || 
       
   202                         iPreviewItemCount.Count() == count )
       
   203                     {
       
   204                     //if the collection is not in Focus,retrive 15 thumbnail and break
       
   205                     GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::HandleItemChanged,iRange=15,aItemIndex=%d",aItemIndex);
       
   206                     break;
       
   207                     }
       
   208 
       
   209                 }
       
   210             }
       
   211         }
       
   212     }
       
   213 
       
   214 // ----------------------------------------------------------------------------
       
   215 // CGlxContentHarvesterPluginCaptured::UpdateDataInCPSL()
       
   216 // ----------------------------------------------------------------------------
       
   217 //  
       
   218 void CGlxContentHarvesterPluginCaptured::UpdateDataInCPSL(TInt aHandle) 
       
   219     {
       
   220     TRACER( "CGlxContentHarvesterPluginCaptured::UpdateDataInCPSL" );
       
   221     //update data in CPS
       
   222     _LIT(KExamplePluginPub,"photossuite");
       
   223     _LIT(KContTypeText,"captured");
       
   224     _LIT(KContId1,"category1");
       
   225 
       
   226     if(iCPSInterface && iMediaList )
       
   227         {
       
   228         CLiwGenericParamList* inParamList = CLiwGenericParamList::NewLC();
       
   229         CLiwGenericParamList* outParamList = CLiwGenericParamList::NewLC();
       
   230 
       
   231         FillInputListWithDataL(inParamList, KExamplePluginPub, KContTypeText , 
       
   232                 KContId1, aHandle);
       
   233 
       
   234         iCPSInterface->ExecuteCmdL( KAdd,  *inParamList, *outParamList );
       
   235         CleanupStack::PopAndDestroy(outParamList);
       
   236         CleanupStack::PopAndDestroy(inParamList);
       
   237         }
       
   238     }
       
   239 
       
   240 // ----------------------------------------------------------------------------
       
   241 // CGlxContentHarvesterPluginCaptured::UpdateItem()
       
   242 // ----------------------------------------------------------------------------
       
   243 //
       
   244 TInt CGlxContentHarvesterPluginCaptured::UpdateItem(TInt aItemIndex)
       
   245     {
       
   246     TRACER( "CGlxContentHarvesterPluginCaptured::UpdateItem" );
       
   247     const TGlxMedia& item = iMediaList->Item(aItemIndex);
       
   248     TSize gridIconSize = GetGridIconSize();
       
   249     TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, 
       
   250             GlxFullThumbnailAttributeId( ETrue,  gridIconSize.iWidth, gridIconSize.iHeight ) );
       
   251     GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::UpdateItem,aItemIndex=%d ",aItemIndex);
       
   252     const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute );
       
   253     if (value)
       
   254         {
       
   255         GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::UpdateItem,iProgressIndex=%d ",iProgressIndex);
       
   256         iProgressIndex++;
       
   257         if (iProgressIndex >= KPreviewThumbnailFetchCount || 
       
   258                 iProgressIndex >= iPreviewItemCount.Count() ||
       
   259                 iProgressIndex >= iMediaList->Count())
       
   260             {
       
   261             iProgressIndex = 0;
       
   262             }
       
   263         return value->iBitmap->Handle();
       
   264         }
       
   265     return KErrNotFound;
       
   266     }
       
   267 
       
   268 // ----------------------------------------------------------------------------
       
   269 // CGlxContentHarvesterPluginCaptured::ActivateL()
       
   270 // ----------------------------------------------------------------------------
       
   271 //
       
   272 void CGlxContentHarvesterPluginCaptured::ActivateL( TBool aOn )
       
   273     {
       
   274     TRACER( "CGlxContentHarvesterPluginCaptured::ActivateL" );
       
   275 
       
   276     GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::ActivateL aOn =%d",aOn);
       
   277     SetFocus(aOn);
       
   278 
       
   279     if (IsMatrixMenuInForegroundL() && aOn && !iPeriodic->IsActive() )
       
   280         {
       
   281 
       
   282         if(GetCHPlugin()->IsRefreshNeeded())
       
   283             {
       
   284             //Update the rest of all the collections on receving the focus...
       
   285             GetCHPlugin()->UpdatePlugins(aOn);          
       
   286             }
       
   287         else
       
   288             {
       
   289             //As the collection is not updated by the contentharvester plugin
       
   290             //to update the thumbnails on the focus , need to call the below function
       
   291             UpdatePreviewThumbnailListL();
       
   292             }
       
   293 
       
   294         iPeriodic->Start( KTimerInterval, 
       
   295                 KTimerInterval, 
       
   296                 TCallBack( TimerCallbackL, this ) );
       
   297         }
       
   298     else if ( !aOn )
       
   299         {
       
   300         if(!IsMatrixMenuInForegroundL())
       
   301             {
       
   302             //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode...
       
   303             //Need to destroy all the collection's observers and context
       
   304             GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::ActivateL !aOn =%d and matrix not in foreground",aOn);
       
   305             GetCHPlugin()->UpdatePlugins(aOn);
       
   306             }
       
   307         iPeriodic->Cancel();
       
   308         }
       
   309     }
       
   310 
       
   311 // ----------------------------------------------------------------------------
       
   312 // CGlxContentHarvesterPluginCaptured::HandleItemAddedL
       
   313 // ----------------------------------------------------------------------------
       
   314 //
       
   315 void CGlxContentHarvesterPluginCaptured::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, 
       
   316         MGlxMediaList* /*aList*/)
       
   317     {
       
   318     TRACER( "CGlxContentHarvesterPluginCaptured::HandleItemAddedL" );
       
   319     }
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // CGlxContentHarvesterPluginCaptured::HandleMediaL
       
   323 // ---------------------------------------------------------------------------
       
   324 //
       
   325 void CGlxContentHarvesterPluginCaptured::HandleMediaL(TInt /*aListIndex*/, 
       
   326         MGlxMediaList* /*aList*/)
       
   327     {
       
   328     TRACER( "CGlxContentHarvesterPluginCaptured::HandleMediaL" );
       
   329     } 
       
   330 
       
   331 // ---------------------------------------------------------------------------
       
   332 // CGlxContentHarvesterPluginCaptured::HandleItemRemovedL
       
   333 // ---------------------------------------------------------------------------
       
   334 //
       
   335 void CGlxContentHarvesterPluginCaptured::HandleItemRemovedL(TInt /*aStartIndex*/, 
       
   336         TInt /* aEndIndex */, MGlxMediaList* /*aList*/)
       
   337     {
       
   338     TRACER( "CGlxContentHarvesterPluginCaptured::HandleItemRemovedL" );
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------------------------
       
   342 // CGlxContentHarvesterPluginCaptured::HandleItemModifiedL
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 void CGlxContentHarvesterPluginCaptured::HandleItemModifiedL(
       
   346         const RArray<TInt>& /*aItemIndexes*/, 
       
   347         MGlxMediaList* /*aList*/)
       
   348     {
       
   349     TRACER( "CGlxContentHarvesterPluginCaptured::HandleItemModifiedL" );
       
   350     }
       
   351 
       
   352 // ---------------------------------------------------------------------------
       
   353 // CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 void CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL(TInt aItemIndex, 
       
   357         const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList)
       
   358     {
       
   359     TRACER( "CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL" );
       
   360     TSize gridIconSize = GetGridIconSize();
       
   361     TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, 
       
   362             GlxFullThumbnailAttributeId( ETrue,  gridIconSize.iWidth, gridIconSize.iHeight ) );
       
   363 
       
   364     TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match );
       
   365     GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL =%d ",aItemIndex);
       
   366     if (KErrNotFound != aAttributes.Find( thumbnailAttribute, match ))
       
   367         {
       
   368         const TGlxMedia& item = aList->Item( aItemIndex );
       
   369         const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute );
       
   370         if (value)
       
   371             {
       
   372             GLX_LOG_INFO("CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL Thumbnail is present ");
       
   373             iPreviewItemCount.InsertInOrder(aItemIndex);
       
   374 
       
   375             //if the collection on the matrix menu is not focused,then show only one thumbnail
       
   376             if(!IsFocused())
       
   377                 {
       
   378                 GLX_LOG_INFO("CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL,one thumbnail fetched");
       
   379                 UpdateDataInCPSL( value->iBitmap->Handle());
       
   380                 //if one thumbnail is fetched,it is sufficent when the collection is not in focus.
       
   381                 //remove the observer as client need not listen to the callbacks               
       
   382                 iMediaList->RemoveMediaListObserver( this );
       
   383                 }
       
   384             else if (iPreviewItemCount.Count()  == KPreviewThumbnailFetchCount || 
       
   385                     iPreviewItemCount.Count() == aList->Count() )
       
   386                 {
       
   387                 GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::HandleAttributesAvailableL,media list count=%d",aList->Count());
       
   388                 //if the PreviewItemCount  equals 15 or if it is eqaul to the total count
       
   389                 //remove the observer as client need not listen to the callbacks 
       
   390                 iMediaList->RemoveMediaListObserver( this );
       
   391                 }
       
   392             }//end of  check against value 
       
   393         }//end of  attribute match
       
   394     }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // CGlxContentHarvesterPluginCaptured::HandleFocusChangedL
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 void CGlxContentHarvesterPluginCaptured::HandleFocusChangedL(
       
   401         NGlxListDefs::TFocusChangeType /*aType*/, 
       
   402         TInt /*aNewIndex*/, 
       
   403         TInt /*aOldIndex*/, 
       
   404         MGlxMediaList* /*aList*/)
       
   405     {
       
   406     TRACER( "CGlxContentHarvesterPluginCaptured::HandleFocusChangedL" );
       
   407     }
       
   408 
       
   409 
       
   410 // ---------------------------------------------------------------------------
       
   411 // CGlxContentHarvesterPluginCaptured::HandleItemSelectedL
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 void CGlxContentHarvesterPluginCaptured::HandleItemSelectedL(TInt /*aIndex*/, 
       
   415         TBool /*aSelected*/, 
       
   416         MGlxMediaList* /*aList*/)
       
   417     {
       
   418     TRACER( "CGlxContentHarvesterPluginCaptured::HandleItemSelectedL" );
       
   419     }
       
   420 
       
   421 // ---------------------------------------------------------------------------
       
   422 // CGlxContentHarvesterPluginCaptured::HandleMessageL
       
   423 // ---------------------------------------------------------------------------
       
   424 //
       
   425 void CGlxContentHarvesterPluginCaptured::HandleMessageL(const CMPXMessage& /*aMessage*/, 
       
   426         MGlxMediaList* /*aList*/)
       
   427     {
       
   428     // Do nothing
       
   429     TRACER( "CGlxContentHarvesterPluginCaptured::HandleMessageL" );
       
   430     }   
       
   431 
       
   432 // ---------------------------------------------------------------------------
       
   433 // CGlxContentHarvesterPluginCaptured::DestroyMedialist
       
   434 // ---------------------------------------------------------------------------
       
   435 //
       
   436 void CGlxContentHarvesterPluginCaptured::DestroyMedialist()
       
   437     {
       
   438     TRACER( "CGlxContentHarvesterPluginCaptured::DestroyMedialist" );
       
   439     if( iMediaList )
       
   440         {
       
   441         GLX_LOG_INFO("CGlxContentHarvesterPluginCaptured::DestroyMedialist,media list deleted");
       
   442         RemoveContextAndObserver();
       
   443         delete iThumbnailContext;
       
   444         iThumbnailContext = NULL;
       
   445         iMediaList->Close();
       
   446         iMediaList = NULL;
       
   447         }
       
   448     }
       
   449 
       
   450 // ---------------------------------------------------------------------------
       
   451 // CGlxContentHarvesterPluginCaptured::CreateMedialistL
       
   452 // ---------------------------------------------------------------------------
       
   453 //
       
   454 void CGlxContentHarvesterPluginCaptured::CreateMedialistL( )
       
   455     {
       
   456     TRACER( "CGlxContentHarvesterPluginCaptured::CreateMedialistL" );
       
   457     if(!iMediaList)
       
   458         {
       
   459         //if the collection is in focus then , create media list with context of 15 items else
       
   460         // with context of single item.
       
   461         if(IsFocused())
       
   462             {
       
   463             iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); 
       
   464             }
       
   465         else
       
   466             {
       
   467             iThumbnailIterator.SetRange( KSinglePreviewThumbnail );
       
   468             }
       
   469 
       
   470         iMediaList = CreateMedialistAndThumbnailContextL( TGlxMediaId( 
       
   471                 KGlxCollectionPluginCameraImplementationUid ),iThumbnailContext);
       
   472         AddContextAndObserverL();
       
   473         }
       
   474     }
       
   475 
       
   476 // ---------------------------------------------------------------------------
       
   477 // CGlxContentHarvesterPluginCaptured::UpdatePreviewThumbnailListL
       
   478 // ---------------------------------------------------------------------------
       
   479 //
       
   480 void CGlxContentHarvesterPluginCaptured::UpdatePreviewThumbnailListL( )
       
   481     {
       
   482     TRACER( "CGlxContentHarvesterPluginCaptured::UpdatePreviewThumbnailListL" );
       
   483 
       
   484     //when there is an update of content in the collection
       
   485     //this function is executed or when the collection recives the focus. 
       
   486     if(!iMediaList)
       
   487         {
       
   488         //medis list is not created yet,create it.
       
   489         CreateMedialistL( );
       
   490         //This is called to show the preview thumbnails. If no thumbnails are
       
   491         //present, display nothing 
       
   492         UpdateDataL();
       
   493         }
       
   494     else if(IsFocused())
       
   495         {
       
   496         //1.This loop is executed,when the collection gets focus
       
   497         //2.This loop is executed,when the contents are updated for this collection
       
   498         //and this collection has focus,so 15 thumbnails are fetched.
       
   499         HandleItemChanged();
       
   500         iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount );
       
   501         RemoveContextAndObserver();
       
   502         AddContextAndObserverL();
       
   503         }
       
   504     else
       
   505         {
       
   506         //1.This loop is executed,when the contents are updated for this collection
       
   507         //and this collection doesn't have the focus,so only one thumbnail is fetched.
       
   508 
       
   509         //here we need to fetch only one item 
       
   510         //1.if the content is deleted,then creating a context doesn't fetch the attributes
       
   511         //2.if the content is added and the content is not the latest as per the sorted order of the
       
   512         // media list,then the thumbnails are not fetched.
       
   513         // so show the first available thumbnail in the media list.
       
   514 
       
   515         HandleItemChanged();
       
   516         UpdateDataL();
       
   517 
       
   518         //Adding the context doesn't gaurantee we get a call back for
       
   519         //Handle attributes available,if the latest item is already fetched.
       
   520         //and for the content added for this collection,if it is not latest
       
   521         //we will not recieve the attributes .so show the first available thumbnail 
       
   522         //in the media list.if there is any new latest content added,the thumbnail will be 
       
   523         //fetched and shown.
       
   524 
       
   525         iThumbnailIterator.SetRange( KSinglePreviewThumbnail );
       
   526         RemoveContextAndObserver();
       
   527         AddContextAndObserverL();
       
   528         }
       
   529     }
       
   530 
       
   531 // ---------------------------------------------------------------------------
       
   532 // CGlxContentHarvesterPluginCaptured::AddContextAndObserverL
       
   533 // ---------------------------------------------------------------------------
       
   534 //
       
   535 void CGlxContentHarvesterPluginCaptured::AddContextAndObserverL()
       
   536     {
       
   537     TRACER( "CGlxContentHarvesterPluginCaptured::AddContextAndObserverL" );   
       
   538     if(iMediaList)
       
   539         {
       
   540         iMediaList->AddMediaListObserverL( this );
       
   541         iMediaList->AddContextL(iThumbnailContext, KGlxFetchContextPriorityNormal);
       
   542         }
       
   543     }
       
   544 
       
   545 // ---------------------------------------------------------------------------
       
   546 // CGlxContentHarvesterPluginCaptured::RemoveContextAndObserver
       
   547 // ---------------------------------------------------------------------------
       
   548 //
       
   549 void CGlxContentHarvesterPluginCaptured::RemoveContextAndObserver()
       
   550     {
       
   551     TRACER( "CGlxContentHarvesterPluginCaptured::RemoveContextAndObserver" );   
       
   552     if(iMediaList)
       
   553         {
       
   554         iMediaList->RemoveMediaListObserver( this );
       
   555         iMediaList->RemoveContext(iThumbnailContext);
       
   556         }
       
   557     }
       
   558 
       
   559 // ---------------------------------------------------------------------------
       
   560 // CGlxContentHarvesterPluginCaptured::HandleError
       
   561 // ---------------------------------------------------------------------------
       
   562 //
       
   563 void CGlxContentHarvesterPluginCaptured::HandleError(TInt /*aError*/)
       
   564     {
       
   565     TRACER( "CGlxContentHarvesterPluginCaptured::HandleError" );    
       
   566 
       
   567 #ifdef _DEBUG
       
   568     if(iMediaList)
       
   569         {
       
   570         TInt count=iMediaList->Count();
       
   571         GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::HandleError,count=%d",count);
       
   572         for ( TInt i = 0; i < count ; i++ )
       
   573             {
       
   574             const TGlxMedia& item = iMediaList->Item( i );
       
   575             TInt thumbnailError = GlxErrorManager::HasAttributeErrorL(
       
   576                     item.Properties(), KGlxMediaIdThumbnail );
       
   577             GLX_LOG_INFO1("CGlxContentHarvesterPluginCaptured::HandleError,Error=%d ",thumbnailError);
       
   578 
       
   579             }
       
   580         }
       
   581 #endif
       
   582     }
       
   583 
       
   584 // ---------------------------------------------------------------------------
       
   585 // CGlxContentHarvesterPluginCaptured::Count
       
   586 // ---------------------------------------------------------------------------
       
   587 //
       
   588 TInt CGlxContentHarvesterPluginCaptured::Count()
       
   589     {
       
   590     TRACER( "CGlxContentHarvesterPluginCaptured::Count" );    
       
   591     TInt count = KErrNone;
       
   592     if(iMediaList)
       
   593         {
       
   594         count = iMediaList->Count();
       
   595         GLX_LOG_INFO1("GlxCHP:Captured::Count(%d)",count);
       
   596         }
       
   597     return count;
       
   598     }
       
   599 //  End of File
       
   600