photosgallery/viewframework/views/metadatadialog/src/glxmetadatacontainer.cpp
branchRCL_3
changeset 26 5b3385a43d68
child 27 34937ec34dac
equal deleted inserted replaced
25:8e5f6eea9c9f 26: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:    Implementation of Metadata dialog
       
    15 *
       
    16 */
       
    17 
       
    18 #include  "glxmetadatacontainer.h"
       
    19 #include  "glxustringconverter.h"        		 // converts the symbian types to UString type
       
    20 #include  "mglxmetadatadialogobserver.h"
       
    21 
       
    22 #include  <StringLoader.h>
       
    23 #include  <caf/manager.h>                         // For Filesystem
       
    24 #include  <ExifModify.h>                          // For CExifModify 
       
    25 #include  <mpxcommandgeneraldefs.h>               // Content ID identifying general category of content provided
       
    26 #include  <mpxmediadrmdefs.h>
       
    27 #include  <eikfrlb.h>                             // For marquee  
       
    28 #include  <eikfrlbd.h>                            // For marquee
       
    29 
       
    30 #include  <glxmetadatadialog.rsg>
       
    31 #include  <glxscreenfurniture.h>
       
    32 #include  <glxdetailsboundcommand.hrh>
       
    33 #include  <glxcommandhandleraddtocontainer.h>     // For CGlxCommandHandlerAddToContainer
       
    34 #include  <glxcommandhandlers.hrh>                // for command handler id
       
    35 #include  <glxcommandfactory.h>                   // for command factory
       
    36 #include  <glxtextentrypopup.h>
       
    37 #include  <glxuistd.h>
       
    38 #include  <glxcollectionplugintags.hrh>       	  // tag collection plugin uid
       
    39 #include  <glxattributeretriever.h>               // CGlxAttributeReteiver
       
    40 #include  <glxdrmutility.h>                       // For launching DRM details pane
       
    41 #include  <glxgeneraluiutilities.h>               // General utilties class definition
       
    42 #include  <glxuiutilities.rsg>                    
       
    43 #include  <glxfilterfactory.h>
       
    44 #include  <glxlog.h>
       
    45 #include  <glxtracer.h>
       
    46 #include <glxgeneraluiutilities.h>
       
    47 
       
    48 const TInt KMediaListId  			 = 0x2000D248;
       
    49 const TInt KOffsets					 = 50;
       
    50 const TInt KMarqueeLoopCount         = 3;
       
    51 const TInt KMarqueeScrollAmount      = 20;
       
    52 const TInt KMarqueeScrollDelay       = 1000000;
       
    53 const TInt KMarqueeScrollInterval    = 200000;
       
    54 
       
    55 _LIT( KGlxComma, ",");
       
    56 
       
    57 // ============================ MEMBER FUNCTIONS ===============================
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // NewL
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 CGlxMetadataContainer* CGlxMetadataContainer::NewL(const TRect& aRect,
       
    64         MGlxMetadataDialogObserver& aDialogObserver, const TDesC& item,
       
    65         MToolbarResetObserver& aResetToolbarObs)
       
    66     {
       
    67     TRACER("CGlxMetadataContainer::NewL");
       
    68     CGlxMetadataContainer* self = CGlxMetadataContainer::NewLC(aRect,
       
    69             aDialogObserver, item, aResetToolbarObs);
       
    70     CleanupStack::Pop(self);
       
    71     return self;
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // NewLC
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 CGlxMetadataContainer* CGlxMetadataContainer::NewLC(const TRect& aRect,
       
    79         MGlxMetadataDialogObserver& aDialogObserver, const TDesC& aUri,
       
    80         MToolbarResetObserver& aResetToolbarObs)
       
    81     {
       
    82     TRACER("CGlxMetadataContainer::NewLC");
       
    83     CGlxMetadataContainer* self = new (ELeave) CGlxMetadataContainer(
       
    84             aDialogObserver, aResetToolbarObs);
       
    85     CleanupStack::PushL(self);
       
    86     self->ConstructL(aRect, aUri);
       
    87     return self;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // CGlxMetadataContainer
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 CGlxMetadataContainer::CGlxMetadataContainer(
       
    95         MGlxMetadataDialogObserver& aDialogObserver,
       
    96         MToolbarResetObserver& aResetToolbarObs) :
       
    97     iDialogObesrver(aDialogObserver), iResetToolbarObs(aResetToolbarObs)
       
    98     {
       
    99     // No implementation
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------
       
   103 // CGlxMetadataContainer::ConstructL
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 void CGlxMetadataContainer::ConstructL(const TRect& /*aRect*/,
       
   107         const TDesC& aUri)
       
   108     {
       
   109     TRACER("CGlxMetadataContainer::ConstructL");
       
   110 
       
   111     //media's uri
       
   112     iUri = aUri.AllocL();
       
   113 
       
   114     //Creating the RBuf texts for all the items except tags & albums
       
   115     //which would be updated as whne the item is edited
       
   116     iTextSetter.CreateL(KMaxFileName);
       
   117 
       
   118     //RBuf text which would be updated as when a tag is edited for the item.
       
   119     iTagSetter.CreateL(KMaxFileName);
       
   120 
       
   121     //RBuf text which would be updated as when a album is edited for the item.
       
   122     iAlbumSetter.CreateL(KMaxFileName);
       
   123 
       
   124     //Create medialist filtered by uri - iUri
       
   125     CreateMediaListForSelectedItemL();
       
   126 
       
   127     //Setting the iVideo flag to EFalse initially
       
   128     iVideo = EFalse;
       
   129 
       
   130     //Setting the iMarquee flag to EFalse initially
       
   131     iMarquee = EFalse;
       
   132 
       
   133     //check when Remove location information is selected.
       
   134     iLocationinfo = EFalse;
       
   135 
       
   136     //Flag to indicate rename command is started
       
   137     iRenameStarted = EFalse;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // ~CGlxMetadataContainer
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 CGlxMetadataContainer::~CGlxMetadataContainer()
       
   145 	{
       
   146 	TRACER("CGlxMetadataContainer::~CGlxMetadataContainer");
       
   147 	if( iItemMediaList )
       
   148 		{
       
   149 		iItemMediaList->RemoveContext(iMainListAttributecontext);
       
   150 		iItemMediaList->RemoveMediaListObserver(this);
       
   151 		iItemMediaList->Close();
       
   152 		iItemMediaList = NULL;
       
   153 		}
       
   154     if ( iTagMediaList )
       
   155 		{
       
   156 		iTagMediaList->RemoveContext(iTagContext);
       
   157 		iTagMediaList->RemoveMediaListObserver(this);
       
   158 		iTagMediaList->Close();
       
   159 		iTagMediaList = NULL;
       
   160 		}
       
   161     if ( iAlbumMediaList )
       
   162 		{
       
   163 		iAlbumMediaList->RemoveContext(iAlbumContext);
       
   164 		iAlbumMediaList->RemoveMediaListObserver(this);
       
   165 		iAlbumMediaList->Close();
       
   166 		iAlbumMediaList = NULL;
       
   167 		}
       
   168     if( iTagContext )
       
   169 		{
       
   170         delete iTagContext;
       
   171         iTagContext = NULL;
       
   172 		}
       
   173     if( iAlbumContext )
       
   174 		{
       
   175         delete iAlbumContext;
       
   176         iAlbumContext = NULL;
       
   177 		}
       
   178     if( iMainListAttributecontext )
       
   179         {
       
   180         delete iMainListAttributecontext;
       
   181         iMainListAttributecontext = NULL;
       
   182         }
       
   183     if( IsVisible() )
       
   184 	    {
       
   185 	    MakeVisible(EFalse);
       
   186 	    }
       
   187     iTextSetter.Close();
       
   188     iTagSetter.Close();
       
   189     iAlbumSetter.Close();
       
   190 
       
   191 	if(iUri)
       
   192 		{
       
   193 		delete iUri;
       
   194 		iUri = NULL;
       
   195 		}
       
   196 	}
       
   197 
       
   198 //-----------------------------------------------------------------------------
       
   199 // CGlxMetadataContainer::MediaList
       
   200 //-----------------------------------------------------------------------------
       
   201 MGlxMediaList& CGlxMetadataContainer::MediaList()
       
   202     {
       
   203     //returns the active medialist.
       
   204     return *iItemMediaList;
       
   205     }
       
   206 
       
   207 //-----------------------------------------------------------------------------
       
   208 // CGlxMetadataContainer::CreateSettingItemL
       
   209 //-----------------------------------------------------------------------------
       
   210 CAknSettingItem* CGlxMetadataContainer::CreateSettingItemL(TInt aResourceId)
       
   211     {
       
   212     TRACER("CGlxMetadataContainer::CreateSettingItemL");
       
   213     CAknSettingItem* settingItem = NULL; // No need to push onto cleanup stack
       
   214     iTextSetter.Zero();
       
   215 
       
   216     // Creating a empty Settings list box which will  be populated 
       
   217     // with metadata in handleattributeavailable
       
   218     switch (aResourceId)
       
   219         {
       
   220         case ENameItem:
       
   221         case EDateAndTimeItem:
       
   222         case EDescriptionItem:
       
   223             {
       
   224             settingItem = new (ELeave) CAknTextSettingItem(aResourceId,
       
   225                     iTextSetter);
       
   226 
       
   227             break;
       
   228             }
       
   229         case ETagsItem:
       
   230             {
       
   231             settingItem = new (ELeave) CAknTextSettingItem(aResourceId,
       
   232                     iTagSetter);
       
   233             break;
       
   234             }
       
   235         case EAlbumsItem:
       
   236             {
       
   237             settingItem = new (ELeave) CAknTextSettingItem(aResourceId,
       
   238                     iAlbumSetter);
       
   239             break;
       
   240             }
       
   241         case ELocationItem:
       
   242         case ESizeItem:
       
   243         case EResolutionItem:
       
   244             {
       
   245             settingItem = new (ELeave) CAknTextSettingItem(aResourceId,
       
   246                     iTextSetter);
       
   247 
       
   248             break;
       
   249             }
       
   250         case EDurationItem:
       
   251         case ElicenseItem:
       
   252             {
       
   253             settingItem = new (ELeave) CAknTextSettingItem(aResourceId,
       
   254                     iTextSetter);
       
   255             //Hide the item until we get the attributes
       
   256             //where in we check for the usage rights.                                                                                                            
       
   257             settingItem->SetHidden(ETrue);
       
   258             //Required to refresh the listbox when any items visiblity is changed
       
   259             this->HandleChangeInItemArrayOrVisibilityL();
       
   260             }
       
   261             break;
       
   262 
       
   263         default:
       
   264             {
       
   265             break;
       
   266             }
       
   267         }
       
   268     return settingItem;
       
   269     }
       
   270 
       
   271 //-----------------------------------------------------------------------------
       
   272 // CGlxMetadataContainer::IsItemModifiable
       
   273 //-----------------------------------------------------------------------------
       
   274 TBool CGlxMetadataContainer::IsItemModifiable()
       
   275     {
       
   276     TRACER("CGlxMetadataContainer::IsItemModifiable");   
       
   277     //Only items like name , description, tag and albums are modifiable
       
   278     //The check is for the items from ENameItem(0) tille ETagsItem(4)
       
   279     if(ListBox()->CurrentItemIndex()<=ETagsItem)
       
   280         {
       
   281         return EFalse;
       
   282         }
       
   283     //return ETrue to dim the item
       
   284     return ETrue;
       
   285     }
       
   286 
       
   287 //-----------------------------------------------------------------------------
       
   288 // CGlxMetadataContainer::IsLocationItem
       
   289 //-----------------------------------------------------------------------------
       
   290 TBool CGlxMetadataContainer::IsLocationItem()
       
   291     {
       
   292     TRACER("CGlxMetadataContainer::IsLocationItem");
       
   293     //if its location item - enable the delete option
       
   294     if (iItemMediaList->Count() && ListBox()->CurrentItemIndex()
       
   295             == ELocationItem)
       
   296         {
       
   297         const TGlxMedia& item = iItemMediaList->Item(0);
       
   298         TCoordinate coordinate;
       
   299         if (item.GetCoordinate(coordinate))
       
   300             {
       
   301             return EFalse;
       
   302             }
       
   303         return ETrue;
       
   304         }
       
   305     //return ETrue to dim the item
       
   306     return ETrue;
       
   307     }
       
   308     
       
   309 //-----------------------------------------------------------------------------
       
   310 // CGlxMetadataContainer::HandleListBoxEventL
       
   311 //-----------------------------------------------------------------------------
       
   312 void CGlxMetadataContainer::HandleListBoxEventL(CEikListBox*  /*aListBox*/,
       
   313                                                     TListBoxEvent aEventType)
       
   314     {
       
   315     GLX_LOG_INFO("CGlxMetadataContainer::HandleListBoxEventL");         
       
   316     if ((aEventType == EEventEnterKeyPressed) || 
       
   317         (aEventType == EEventEditingStarted) ||
       
   318         (aEventType == EEventItemSingleClicked))
       
   319         {
       
   320         //handle edit functionality if items when useer selects via touch
       
   321         HandleListboxChangesL();
       
   322         }
       
   323     }
       
   324 //-----------------------------------------------------------------------------
       
   325 // CGlxMetadataContainer::HandleListboxChangesL
       
   326 //-----------------------------------------------------------------------------
       
   327 void CGlxMetadataContainer::HandleListboxChangesL()
       
   328     {
       
   329     TRACER("CGlxMetadataContainer::HandleListboxChangesL");
       
   330 
       
   331     //dont Edit Item's details if medialist is empty
       
   332     //OR Rename command is in progress
       
   333     if (iItemMediaList->Count() == 0 || iRenameStarted)
       
   334         {
       
   335         GLX_LOG_INFO("MediaList empty or Rename command started");
       
   336         return;
       
   337         }
       
   338 
       
   339     TInt index = ListBox()->CurrentItemIndex();
       
   340 
       
   341     switch (index)
       
   342         {
       
   343         case ENameItem:
       
   344         case EDescriptionItem:
       
   345             {
       
   346             SetNameDescriptionL(index);
       
   347             break;
       
   348             }
       
   349         case ETagsItem:
       
   350             {
       
   351             //Set the focus of the item
       
   352             iItemMediaList->SetFocusL(NGlxListDefs::EAbsolute, 0);
       
   353             //Launch add to container commandhandler via dialog observer.
       
   354             iDialogObesrver.AddTagL();
       
   355             break;
       
   356             }
       
   357         case EAlbumsItem:
       
   358             {
       
   359             //Set the focus of the item
       
   360             iItemMediaList->SetFocusL(NGlxListDefs::EAbsolute, 0);
       
   361             //Launch add to container commandhandler via dialog observer.
       
   362             iDialogObesrver.AddAlbumL();
       
   363             break;
       
   364             }
       
   365         case ELocationItem:
       
   366             {
       
   367             // Get the Media Item
       
   368             const TGlxMedia& media = iItemMediaList->Item(0);
       
   369             // Test to see if the Coordinate is Present
       
   370             TCoordinate coordinate;
       
   371             if (!media.GetCoordinate(coordinate))
       
   372                 {
       
   373                 HBufC *noLocationBuf = StringLoader::LoadLC(
       
   374                         R_GLX_METADATA_NOTE_INFO_NO_LOCATION);
       
   375                 GlxGeneralUiUtilities::ShowInfoNoteL(*noLocationBuf, ETrue);
       
   376                 CleanupStack::PopAndDestroy(noLocationBuf);
       
   377                 }
       
   378 			else
       
   379 				{
       
   380 				CAknSettingItem* settingsitem = (*SettingItemArray())[index]; 
       
   381 			    GlxGeneralUiUtilities::ShowInfoNoteL(settingsitem->SettingTextL(),ETrue);
       
   382 				}
       
   383             break;
       
   384             }
       
   385         case EDurationItem:
       
   386             {
       
   387             //This is condition is useful when the license item is selected for a image file
       
   388             if (iVideo)
       
   389                 {
       
   390                 break;
       
   391                 }
       
   392             }
       
   393         case EResolutionItem:
       
   394         	{
       
   395 			//This is condition is useful when the license item is selected for a DRM Video file
       
   396 			if (!iVideo || !iItemMediaList->Item(0).IsDrmProtected())
       
   397 				{
       
   398 				break;
       
   399 				}
       
   400 			}
       
   401         case ElicenseItem:
       
   402             {
       
   403             const TGlxMedia& item = iItemMediaList->Item(0);
       
   404             if (item.IsDrmProtected())
       
   405                 {
       
   406                 //Create DRM utility
       
   407                 CGlxDRMUtility* drmUtility = CGlxDRMUtility::InstanceL();
       
   408                 CleanupClosePushL(*drmUtility);
       
   409 
       
   410                 // check if rights have expired
       
   411                 TBool expired = EFalse;
       
   412                 expired = !drmUtility->ItemRightsValidityCheckL(item.Uri(),
       
   413                         EMPXImage == item.Category());
       
   414 
       
   415                 if (expired)
       
   416                     {
       
   417                     drmUtility->ShowRightsInfoL(item.Uri());
       
   418                     }
       
   419                 else
       
   420                     {
       
   421                     drmUtility->ShowDRMDetailsPaneL(item.Uri());
       
   422                     }
       
   423                 CleanupStack::PopAndDestroy(drmUtility);
       
   424                 }
       
   425             }
       
   426             break;
       
   427         default:
       
   428             {
       
   429             break;
       
   430             }
       
   431         }
       
   432     }
       
   433 //-----------------------------------------------------------------------------
       
   434 // CGlxMetadataContainer::CreateMediaListForSelectedItemL
       
   435 //-----------------------------------------------------------------------------
       
   436 void CGlxMetadataContainer::CreateMediaListForSelectedItemL( )
       
   437     {
       
   438     TRACER("CGlxMetadataContainer::CreateMediaListForSelectedItemL");
       
   439 
       
   440     //create the collection path for the medialist to be created
       
   441     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   442     CleanupStack::PushL(path);
       
   443     //set the all collection path as the details dialog can be launched from any of the grid views and filter with URI
       
   444     path->AppendL(KGlxCollectionPluginAllImplementationUid);
       
   445     //create the filter with the URI
       
   446     CMPXFilter* filter = TGlxFilterFactory::CreateURIFilterL(*iUri);
       
   447     CleanupStack::PushL(filter);
       
   448     //create the medialist
       
   449     iItemMediaList = MGlxMediaList::InstanceL(*path, TGlxHierarchyId(
       
   450             KMediaListId), filter);
       
   451 
       
   452     //Add the attributes which are required to be displayed.
       
   453     iMainListAttributecontext = new (ELeave) CGlxAttributeContext(
       
   454             &iSelectionIterator);
       
   455     iMainListAttributecontext->AddAttributeL(KMPXMediaDrmProtected);
       
   456     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralCategory);
       
   457     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralSize);
       
   458     iMainListAttributecontext->AddAttributeL(KGlxMediaGeneralDimensions);
       
   459     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralTitle);
       
   460     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralDate);
       
   461     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralComment);
       
   462     iMainListAttributecontext->AddAttributeL(KGlxMediaGeneralLocation);
       
   463     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralDuration);
       
   464     iMainListAttributecontext->AddAttributeL(KMPXMediaGeneralUri);
       
   465 
       
   466     //Add Context so that we get the handleattributes call once the medialist is populated with above mentioned attributes.
       
   467     iItemMediaList->AddContextL(iMainListAttributecontext,
       
   468             KGlxFetchContextPriorityBlocking);
       
   469 
       
   470     //add to observer for callbacks.
       
   471     iItemMediaList->AddMediaListObserverL(this);
       
   472 
       
   473     CleanupStack::PopAndDestroy(filter);
       
   474     CleanupStack::PopAndDestroy(path);
       
   475     }
       
   476 
       
   477 //-----------------------------------------------------------------------------
       
   478 // CGlxMetadataContainer::CreateTagsMediaList
       
   479 //-----------------------------------------------------------------------------
       
   480 void CGlxMetadataContainer::CreateTagsMediaListL()
       
   481     {
       
   482     TRACER("CGlxMetadataContainer::CreateTagsMediaListL");
       
   483     //create the collection path for the medialist to be created
       
   484     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   485     CleanupStack::PushL(path);
       
   486     //Set the Tags collection for the particular item
       
   487     path->AppendL(KGlxTagCollectionPluginImplementationUid);
       
   488     //get the media item for which we require the tags collection
       
   489     TGlxMedia item = iItemMediaList->Item(0);
       
   490     //create the medialist filter with media ID
       
   491     CMPXFilter* filter1 =
       
   492             TGlxFilterFactory::CreateExcludeContainersWithoutItemFilterL(
       
   493                     item.Id());
       
   494     CleanupStack::PushL(filter1);
       
   495     //set the array order as required, here its alphabetical
       
   496     TGlxFilterProperties filterProperty;
       
   497     filterProperty.iSortOrder = EGlxFilterSortOrderAlphabetical;
       
   498     filterProperty.iSortDirection = EGlxFilterSortDirectionAscending;
       
   499     //combine the filter with filterProperty
       
   500     CMPXFilter* filter = TGlxFilterFactory::CreateCombinedFilterL(
       
   501             filterProperty, filter1, EFalse);
       
   502     CleanupStack::PushL(filter);
       
   503 
       
   504     //create the medialist to get the tags array.
       
   505     iTagMediaList = MGlxMediaList::InstanceL(*path, TGlxHierarchyId(
       
   506             KMediaListId), filter);
       
   507 
       
   508     //add the attribute KMPXMediaGeneralTitle to the context to get the tag name
       
   509     iTagContext = CGlxDefaultAttributeContext::NewL();
       
   510     iTagContext->AddAttributeL(KMPXMediaGeneralTitle);
       
   511     iTagContext->SetRangeOffsets(KOffsets, KOffsets);
       
   512 
       
   513     //Add Context so that we get the handleattributes call once the medialist is populated with tags.
       
   514     iTagMediaList->AddContextL(iTagContext,
       
   515             KGlxFetchContextPriorityUMPViewTagPane);
       
   516 
       
   517     //add to observer for callbacks.                                      
       
   518     iTagMediaList->AddMediaListObserverL(this);
       
   519 
       
   520     CleanupStack::PopAndDestroy(filter);
       
   521     CleanupStack::PopAndDestroy(filter1);
       
   522     CleanupStack::PopAndDestroy(path);
       
   523     }
       
   524 
       
   525 //-----------------------------------------------------------------------------
       
   526 // CGlxMetadataContainer::CreateAlbumsMediaListL
       
   527 //-----------------------------------------------------------------------------
       
   528 void CGlxMetadataContainer::CreateAlbumsMediaListL()
       
   529     {
       
   530     TRACER("CGlxMetadataContainer::CreateAlbumsMediaListL");
       
   531     //create the collection path for the medialist to be created
       
   532     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   533     CleanupStack::PushL(path);
       
   534     //Set the albums collection for the particular item
       
   535     path->AppendL(KGlxCollectionPluginAlbumsImplementationUid);
       
   536     //get the media item for which we require the tags collection
       
   537     TGlxMedia item = iItemMediaList->Item(0);
       
   538     //create the medialist filter with media ID
       
   539     CMPXFilter* filter =
       
   540             TGlxFilterFactory::CreateExcludeContainersWithoutItemFilterL(
       
   541                     item.Id());
       
   542     CleanupStack::PushL(filter);
       
   543     //create the albums medialist.
       
   544     iAlbumMediaList = MGlxMediaList::InstanceL(*path, TGlxHierarchyId(
       
   545             KMediaListId), filter);
       
   546 
       
   547     //add the attribute KMPXMediaGeneralTitle to the context to get the album name
       
   548     iAlbumContext = CGlxDefaultAttributeContext::NewL();
       
   549     iAlbumContext->AddAttributeL(KMPXMediaGeneralTitle);
       
   550     iAlbumContext->SetRangeOffsets(KOffsets, KOffsets);
       
   551     //Add Context to the medialist so that we get the handleattributes call once the medialist is populated with albums.
       
   552     iAlbumMediaList->AddContextL(iAlbumContext,
       
   553             KGlxFetchContextPriorityUMPViewAlbumPane);
       
   554 
       
   555     //add to observer for callbacks. 
       
   556     iAlbumMediaList->AddMediaListObserverL(this);
       
   557 
       
   558     CleanupStack::PopAndDestroy(filter);
       
   559     CleanupStack::PopAndDestroy(path);
       
   560     }
       
   561 
       
   562 // ----------------------------------------------------------------------------
       
   563 // CGlxMetadataContainer::ViewDynInitMenuPaneL
       
   564 // ----------------------------------------------------------------------------
       
   565 // 
       
   566 void CGlxMetadataContainer::ViewDynInitMenuPaneL(TInt aMenuId,
       
   567         CEikMenuPane* aMenuPane)
       
   568     {
       
   569     if (aMenuId == R_METADATA_MENU)
       
   570         {
       
   571         //Set dim the options based on the item selected
       
   572         //location info will be enabled if the item has a location info
       
   573         aMenuPane->SetItemDimmed(KGlxDeleteBoundMenuCommandId,
       
   574                 IsLocationItem());
       
   575         }
       
   576     }
       
   577 
       
   578 // ----------------------------------------------------------------------------
       
   579 // CGlxMetadataContainer::RemoveLocationL
       
   580 // ----------------------------------------------------------------------------
       
   581 //
       
   582 void CGlxMetadataContainer::RemoveLocationL() 
       
   583     {
       
   584     TRACER("CGlxMetadataContainer::RemoveLocationL");
       
   585 
       
   586     iLocationinfo = ETrue;
       
   587     // get the media item
       
   588     const TGlxMedia& media = iItemMediaList->Item(0);
       
   589     // Test to see if the coordinate is present
       
   590     TCoordinate coordinate;
       
   591     TBool isSupported = media.GetCoordinate(coordinate);
       
   592     if (!isSupported)
       
   593         {
       
   594         HBufC *buf = StringLoader::LoadLC(
       
   595                 R_GLX_METADATA_NOTE_INFO_NO_LOCATION);
       
   596         GlxGeneralUiUtilities::ShowInfoNoteL(*buf, ETrue);
       
   597         CleanupStack::PopAndDestroy(buf);
       
   598         }
       
   599     else
       
   600         {
       
   601         HBufC *buf =
       
   602                 StringLoader::LoadLC(R_GLX_METADATA_NOTE_DELETE_LOCATION);
       
   603         TBool response = GlxGeneralUiUtilities::ConfirmQueryL(
       
   604                 R_GLX_QUERY_YES_NO, *buf);
       
   605         CleanupStack::PopAndDestroy(buf);
       
   606 
       
   607         if (response)
       
   608             {
       
   609             //user selected yes, so delete location     
       
   610             //send command for delete location after successfull removal of command remove this pane
       
   611             if (iItemMediaList->Count() > 0)
       
   612                 {
       
   613                 //set focus to first item	
       
   614                 iItemMediaList->SetFocusL(NGlxListDefs::EAbsolute, 0);
       
   615 
       
   616                 // Deleting location information from image file
       
   617                 RFs rFs;
       
   618                 User::LeaveIfError(rFs.Connect());
       
   619                 CleanupClosePushL(rFs);
       
   620                 RFile rFile;
       
   621                 User::LeaveIfError(rFile.Open(rFs,
       
   622                         iItemMediaList->Item(0).Uri(), EFileWrite));
       
   623                 CleanupClosePushL(rFile);
       
   624 
       
   625                 TInt imageFileSize = 0; // Image File Size
       
   626                 User::LeaveIfError(rFile.Size(imageFileSize));
       
   627                 HBufC8* imageData = HBufC8::NewL(imageFileSize); //Actual Image Data
       
   628                 CleanupStack::PushL(imageData);
       
   629 
       
   630                 TPtr8 myImagePtr = imageData->Des();
       
   631                 TInt readError = rFile.Read(myImagePtr);
       
   632                 if (readError != KErrNone)
       
   633                     {
       
   634                     User::Leave(KErrGeneral);
       
   635                     }
       
   636 
       
   637                 //CExifModify Interface class for modifying existing Exif v2.2 (or prior) 
       
   638                 //file format or creating Exif v2.2 file format using valid Jpeg image     
       
   639                 CExifModify* exifWriter = NULL;
       
   640                 TRAPD(err,exifWriter = CExifModify::NewL( imageData->Des()));
       
   641                 CleanupStack::PushL(exifWriter);
       
   642                 if (err == KErrNone)
       
   643                     {
       
   644                     //Removes the specified IFD structure and all its tags from the Exif data
       
   645                     exifWriter->DeleteIfd(EIfdGps);
       
   646 
       
   647                     HBufC8* modifiedExif = exifWriter->WriteDataL(
       
   648                             imageData->Des()); //Modified Image Data
       
   649                     CleanupStack::PushL(modifiedExif);
       
   650 
       
   651                     const TUint32 fileSize = modifiedExif->Des().Length(); //Size of Modified File
       
   652                     TInt oldSize;
       
   653                     rFile.Size(oldSize);
       
   654                     // set position to begin of file & write the Modified data (Without Location Information)
       
   655                     TInt pos = 0;
       
   656                     User::LeaveIfError(rFile.Seek(ESeekStart, pos));
       
   657                     User::LeaveIfError(rFile.Write(modifiedExif->Des(),
       
   658                             fileSize));
       
   659 
       
   660                     TTime lastModified;
       
   661                     lastModified.UniversalTime();
       
   662                     User::LeaveIfError(rFile.SetModified(lastModified)); //Change the Modified Time
       
   663 
       
   664                     CleanupStack::PopAndDestroy(modifiedExif);
       
   665                     }
       
   666                 CleanupStack::PopAndDestroy(exifWriter);
       
   667                 CleanupStack::PopAndDestroy(imageData);
       
   668                 CleanupStack::PopAndDestroy(&rFile);
       
   669                 CleanupStack::PopAndDestroy(&rFs);
       
   670 
       
   671                 //Deleting location information from MDS database
       
   672                 CMPXCollectionPath* path = iItemMediaList->PathLC();
       
   673                 CMPXCommand* command =
       
   674                         TGlxCommandFactory::DeleteLocationCommandLC(*path);
       
   675 
       
   676                 command->SetTObjectValueL<TAny*> (
       
   677                         KMPXCommandGeneralSessionId,
       
   678                         static_cast<TAny*> (this));
       
   679 
       
   680                 iItemMediaList->CommandL(*command);
       
   681                 CleanupStack::PopAndDestroy(command);
       
   682                 CleanupStack::PopAndDestroy(path);
       
   683                 }
       
   684             }
       
   685         }
       
   686     }
       
   687 // ----------------------------------------------------------------------------
       
   688 // CGlxMetadataContainer::EditItemL
       
   689 // ----------------------------------------------------------------------------
       
   690 //
       
   691 void CGlxMetadataContainer::EditItemL(TInt aIndex, TBool /*aCalledFromMenu*/)
       
   692     {
       
   693 	TRACER("CGlxMetadataContainer::EditItemL");   
       
   694     CAknSettingItem* settingsitem = NULL;
       
   695     settingsitem = (*SettingItemArray())[aIndex];
       
   696     settingsitem->LoadL();
       
   697     settingsitem->UpdateListBoxTextL();
       
   698     settingsitem->StoreL();
       
   699     ListBox()->DrawNow();
       
   700     }
       
   701 // ----------------------------------------------------------------------------
       
   702 // CGlxMetadataContainer::SetAttributesL
       
   703 // ----------------------------------------------------------------------------
       
   704 //
       
   705 void CGlxMetadataContainer::SetAttributesL(TMPXAttribute attribute)
       
   706 	{
       
   707     TRACER("CGlxMetadataContainer::SetAttributesL");
       
   708 
       
   709     //create the tags and albums medialist once the item medialist is populated
       
   710     //Tags and albums medialist can be created only with media ID.
       
   711     if (!iTagMediaList)
       
   712         {
       
   713         CreateTagsMediaListL();
       
   714         }
       
   715     if (!iAlbumMediaList)
       
   716         {
       
   717         CreateAlbumsMediaListL();
       
   718         }
       
   719     if (!iSetVisible)
       
   720         {
       
   721         iSetVisible = ETrue;
       
   722         SetDurationLIicenseItemVisibilityL();
       
   723         }
       
   724     TGlxMedia item = iItemMediaList->Item(0);
       
   725     //Create the string convertor instance 
       
   726     //String convertor class with provide the specific format for date,location and duration and size.
       
   727     CGlxUStringConverter* stringConverter = CGlxUStringConverter::NewL();
       
   728     CleanupStack::PushL(stringConverter);
       
   729     HBufC* string = NULL;
       
   730 
       
   731     //if attribute is date and time we need to pass the format it as R_QTN_DATE_USUAL_WITH_ZERO else null
       
   732     if (attribute == KMPXMediaGeneralDate)
       
   733         {
       
   734         stringConverter->AsStringL(item, attribute,
       
   735                 R_QTN_DATE_USUAL_WITH_ZERO, string);
       
   736         }
       
   737     else
       
   738         {
       
   739         stringConverter->AsStringL(item, attribute, 0, string);
       
   740         }
       
   741     //get the settings item based on the attribute and set the text.
       
   742     if (string)
       
   743         {
       
   744         iTextSetter.Zero();
       
   745         iTextSetter.Append(*string);
       
   746         if (attribute == KMPXMediaGeneralSize)
       
   747             {
       
   748             EditItemL(ESizeItem, EFalse);
       
   749             }
       
   750         else if (attribute == KMPXMediaGeneralDuration)
       
   751             {
       
   752             EditItemL(EDurationItem, EFalse);
       
   753             }
       
   754         else if (attribute == KMPXMediaGeneralTitle)
       
   755             {
       
   756             EditItemL(ENameItem, EFalse);
       
   757             }
       
   758         else if (attribute == KMPXMediaGeneralDate)
       
   759             {
       
   760             EditItemL(EDateAndTimeItem, EFalse);
       
   761             }
       
   762         else if (attribute == KMPXMediaGeneralComment)
       
   763             {
       
   764             EditItemL(EDescriptionItem, EFalse);
       
   765             }
       
   766         else if (attribute == KGlxMediaGeneralLocation)
       
   767             {
       
   768             EditItemL(ELocationItem, EFalse);
       
   769             }
       
   770         else if (attribute == KGlxMediaGeneralDimensions)
       
   771             {
       
   772             EditItemL(EResolutionItem, EFalse);
       
   773             }
       
   774         else
       
   775             {
       
   776             }
       
   777         delete string;
       
   778         string = NULL;
       
   779         }
       
   780     CleanupStack::PopAndDestroy(stringConverter);
       
   781     }
       
   782 
       
   783 // ----------------------------------------------------------------------------
       
   784 // CGlxMetadataContainer::SetNameDescriptionL
       
   785 // ----------------------------------------------------------------------------
       
   786 //
       
   787 void CGlxMetadataContainer::SetNameDescriptionL(TInt aItem)
       
   788     {
       
   789     TRACER("CGlxMetadataContainer::SetNameDescriptionL");
       
   790     //This functions i commn for updatng both name and description once modified    
       
   791     //get the item handcle to be modified    	
       
   792     CAknSettingItem* settingsitem = (*SettingItemArray())[aItem];
       
   793     HBufC* textBuf = HBufC::NewLC(KMaxMediaPopupTextLength);
       
   794     const TDesC& popupText = settingsitem->SettingTextL();
       
   795     (textBuf->Des()).Copy(popupText.Left(KMaxMediaPopupTextLength));
       
   796     TPtr textPtr = textBuf->Des();
       
   797     //Remove preceeding & trailing spaces
       
   798     textPtr.Trim();
       
   799     HBufC* buf = NULL;
       
   800 
       
   801     if(aItem == ENameItem)
       
   802         {
       
   803         buf = StringLoader::LoadLC(R_GLX_METADATA_VIEW_TITLE_NSERIES);
       
   804         }
       
   805     else
       
   806         {
       
   807         buf = StringLoader::LoadLC(R_GLX_METADATA_VIEW_DESCRIPTION_NSERIES);
       
   808         }
       
   809 
       
   810     //Launch the text entry editor.
       
   811     CGlxTextEntryPopup* popup = CGlxTextEntryPopup::NewL(*buf, textPtr);
       
   812     CleanupStack::PopAndDestroy(buf);
       
   813     if (aItem == EDescriptionItem)
       
   814         {
       
   815         popup->SetLeftSoftKeyL(ETrue);
       
   816         }
       
   817 
       
   818     //action upon selecting ok from the editor 
       
   819     if (popup->ExecuteLD() == EEikBidOk)
       
   820         {
       
   821 		if(0 != (popupText.Compare(*textBuf)))
       
   822             {
       
   823             TFileName fileName = ParseFileName(*textBuf);
       
   824             //check If filename already exists
       
   825             if ((aItem == ENameItem) && (BaflUtils::FileExists(
       
   826                     ControlEnv()->FsSession(), fileName)))
       
   827                 {
       
   828                 //if changed title is same as existing one then showing the already use popup to user
       
   829                 HBufC* info = StringLoader::LoadLC(R_GLX_NAME_ALREADY_USED,
       
   830                         *textBuf);
       
   831                 GlxGeneralUiUtilities::ShowInfoNoteL(*info, ETrue);
       
   832                 CleanupStack::PopAndDestroy(info);
       
   833                 }
       
   834             // Check if the filename is valid
       
   835             else if ((aItem == ENameItem)
       
   836                     && (!ControlEnv()->FsSession().IsValidName(*textBuf)))
       
   837                 {
       
   838                 //Show illegal characters error note 
       
   839                 HBufC* info = StringLoader::LoadLC(
       
   840                         R_GLX_QTN_FLDR_ILLEGAL_CHARACTERS);
       
   841                 GlxGeneralUiUtilities::ShowInfoNoteL(*info, ETrue);
       
   842                 CleanupStack::PopAndDestroy(info);
       
   843                 }
       
   844             else
       
   845                 {
       
   846                 //Modify the MDS and setting list only if the entry is different from previous Item value
       
   847                 iTextSetter.Zero();
       
   848                 iTextSetter.Copy(*textBuf);
       
   849                 EditItemL(aItem, EFalse);
       
   850                 iItemMediaList->SetFocusL(NGlxListDefs::EAbsolute, 0);//set focus to first item
       
   851 
       
   852                 if (aItem == ENameItem)
       
   853                     {
       
   854                     //indicate Rename command is started
       
   855                     iRenameStarted = ETrue;
       
   856                     //set Setting List Box to Dimmed status
       
   857                     SetDimmed(iRenameStarted);
       
   858 
       
   859                     const TGlxMedia& media = iItemMediaList->Item(0);
       
   860                     ContentAccess::CManager *manager =
       
   861                             ContentAccess::CManager::NewL();
       
   862                     CleanupStack::PushL(manager);
       
   863                     HBufC* modifiedName = fileName.AllocLC();
       
   864 
       
   865                     //rename the media
       
   866                     TInt error = manager->RenameFile(media.Uri(),
       
   867                             *modifiedName);
       
   868                     if (KErrNone == error)
       
   869                         {
       
   870                         //Redundant call But needed in case FileSystem is too slow 
       
   871                         //to notify MDS for updating title.
       
   872                         //Create the glx command for updating Title in MDS
       
   873                         CMPXCollectionPath* path = iItemMediaList->PathLC();
       
   874                         CMPXCommand* command =
       
   875                                 TGlxCommandFactory::RenameCommandLC(
       
   876                                         settingsitem->SettingTextL(), *path);
       
   877                         command->SetTObjectValueL<TAny*> (
       
   878                                 KMPXCommandGeneralSessionId,
       
   879                                 static_cast<TAny*> (this));
       
   880                         //issue command to the medialist which further 
       
   881                         //calls data source to update MDS
       
   882                         iItemMediaList->CommandL(*command);
       
   883                         CleanupStack::PopAndDestroy(command);
       
   884                         CleanupStack::PopAndDestroy(path);
       
   885                         }
       
   886                     else
       
   887                         {
       
   888                         //Renaming commmand failed
       
   889                         iRenameStarted = EFalse;
       
   890                         //reset Setting Items to undim status
       
   891                         SetDimmed(iRenameStarted);
       
   892                         //Reset the EName Settings field
       
   893                         iTextSetter.Zero();
       
   894                         iTextSetter.Copy(media.Title());
       
   895                         EditItemL(ENameItem, EFalse);
       
   896 						GlxGeneralUiUtilities::ShowErrorNoteL(error);
       
   897                         }
       
   898                     CleanupStack::PopAndDestroy(modifiedName);
       
   899                     CleanupStack::PopAndDestroy(manager);
       
   900                     }
       
   901                 else
       
   902                     {
       
   903                     //Create the glx command for changing description
       
   904                     CMPXCollectionPath* path = iItemMediaList->PathLC();
       
   905                     CMPXCommand* command =
       
   906                             TGlxCommandFactory::SetDescriptionCommandLC(
       
   907                                     settingsitem->SettingTextL(), *path);
       
   908                     command->SetTObjectValueL<TAny*> (
       
   909                             KMPXCommandGeneralSessionId,
       
   910                             static_cast<TAny*> (this));
       
   911                     //issue command to the medialist which further 
       
   912                     //calls data source to update MDS
       
   913                     iItemMediaList->CommandL(*command);
       
   914                     CleanupStack::PopAndDestroy(command);
       
   915                     CleanupStack::PopAndDestroy(path);
       
   916                     }
       
   917                 }
       
   918             }
       
   919         }
       
   920     CleanupStack::PopAndDestroy(textBuf);
       
   921 
       
   922     //notify observer that some operation has happened. So refresh the toolbar area..
       
   923     iResetToolbarObs.HandleToolbarResetting(EFalse);
       
   924     }
       
   925 
       
   926 // ----------------------------------------------------------------------------
       
   927 // CGlxMetadataContainer::UpdateTagsL()
       
   928 // ----------------------------------------------------------------------------
       
   929 // 
       
   930 void CGlxMetadataContainer::UpdateTagsL()
       
   931     {
       
   932     TRACER("CGlxMetadataContainer::UpdateTagsL");
       
   933     //Get the tag setting item handle to set the text
       
   934     CAknSettingItem* settingsitem = (*SettingItemArray())[ETagsItem];
       
   935 
       
   936     //Set the tag setter to empty string before filling in the data.                                                
       
   937     iTagSetter.Zero();
       
   938      
       
   939     //Loop to appened all the tags to the iTagSetter.
       
   940     for (TInt index = 0; index < iTagMediaList->Count(); index++)
       
   941         {
       
   942         if (iTagSetter.Length())
       
   943             {
       
   944             iTagSetter.Append(KGlxComma);
       
   945             }
       
   946         const TGlxMedia& item = iTagMediaList->Item(index);
       
   947         const TDesC& title = item.Title();
       
   948         iTagSetter.Append(title);
       
   949         }
       
   950     EditItemL(ETagsItem, EFalse);
       
   951     }
       
   952 
       
   953 // ----------------------------------------------------------------------------
       
   954 // CGlxMetadataContainer::UpdateAlbumsL()
       
   955 // ----------------------------------------------------------------------------
       
   956 // 
       
   957 void CGlxMetadataContainer::UpdateAlbumsL()
       
   958     {
       
   959     TRACER("CGlxMetadataContainer::UpdateAlbumsL");	
       
   960     //Get the tag setting item handle to set the text
       
   961     CAknSettingItem* settingsitem = (*SettingItemArray())[EAlbumsItem];
       
   962 
       
   963     //Set the tag setter to empty string before filling in the data.
       
   964     iAlbumSetter.Zero();
       
   965     
       
   966     //Loop to appened all the tags to the iAlbumSetter.
       
   967     for( TInt index = 0 ; index < iAlbumMediaList->Count() ; index++ )
       
   968 		{
       
   969         if(iAlbumSetter.Length())
       
   970 			{
       
   971 			iAlbumSetter.Append(KGlxComma);
       
   972 			}
       
   973 		const TGlxMedia&  item = iAlbumMediaList->Item( index );
       
   974 		const TDesC& title = item.Title();
       
   975 		iAlbumSetter.Append(title);
       
   976 		}
       
   977 	EditItemL(EAlbumsItem,EFalse);
       
   978     }
       
   979 
       
   980 // ----------------------------------------------------------------------------
       
   981 // CGlxMetadataContainer::SetDurationLIicenseItemVisibilityL()
       
   982 // ----------------------------------------------------------------------------
       
   983 // 
       
   984 void CGlxMetadataContainer::SetDurationLIicenseItemVisibilityL()
       
   985     {
       
   986     TRACER("CGlxMetadataContainer::SetDurationLIicenseItemVisibilityL");		
       
   987     //get the media item.
       
   988     const TGlxMedia& item = iItemMediaList->Item(0);
       
   989     const CGlxMedia* media = item.Properties();
       
   990 
       
   991     //in order to check for video category and drm rights
       
   992 
       
   993     CAknSettingItem* hiddenItem = NULL;
       
   994     if (item.Category() == EMPXVideo)
       
   995         {
       
   996         if (!item.IsDrmProtected())
       
   997             {
       
   998             hiddenItem = (*SettingItemArray())[EDurationItem];
       
   999             //Set the duration item visible
       
  1000             hiddenItem->SetHidden(EFalse);
       
  1001             }
       
  1002         else
       
  1003             {
       
  1004             hiddenItem = (*SettingItemArray())[EResolutionItem];
       
  1005             //Set the Resolution item in-visible for DRM protected Video
       
  1006             hiddenItem->SetHidden(ETrue);
       
  1007             }
       
  1008         //set the video flag which would be used to enable/disable the view details option.               
       
  1009         this->HandleChangeInItemArrayOrVisibilityL();
       
  1010         iVideo = ETrue;
       
  1011         }
       
  1012     if (media && media->IsSupported(KMPXMediaDrmProtected))
       
  1013         {
       
  1014         if (item.IsDrmProtected())
       
  1015             {
       
  1016             hiddenItem = (*SettingItemArray())[ElicenseItem];
       
  1017             //Set the License item visible
       
  1018             hiddenItem->SetHidden(EFalse);
       
  1019             //Required to refresh the listbox when any items visiblity is changed
       
  1020             this->HandleChangeInItemArrayOrVisibilityL();
       
  1021             }
       
  1022         }
       
  1023     }
       
  1024 
       
  1025 //Medialist callbacks.    
       
  1026 // ----------------------------------------------------------------------------
       
  1027 // CGlxMetadataContainer::HandleAttributesAvailableL
       
  1028 // ----------------------------------------------------------------------------
       
  1029 //
       
  1030 void CGlxMetadataContainer::HandleAttributesAvailableL(TInt /*aItemIndex*/,
       
  1031         const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList)
       
  1032     {
       
  1033     TRACER("CGlxMetadataContainer::HandleAttributesAvailableL()");
       
  1034     //generic medialist for the item for all the attributes required other than tags and albums.
       
  1035     if (aList == iItemMediaList)
       
  1036         {
       
  1037         // Loop untill it checks for all the avialable attributes
       
  1038         for (TInt i = aAttributes.Count() - 1; i >= 0; i--)
       
  1039             {
       
  1040             //set attributes to the items in the container
       
  1041             SetAttributesL(aAttributes[i]);
       
  1042             }
       
  1043 
       
  1044         //Here following 2 cases are handled:-
       
  1045         //1) Rename from Photos application or Post-Capture view
       
  1046         //- HandleAttributeavailable - new title & new uri at same time.
       
  1047         //May come twice here since Redundant Rename CMD sent to MDS.
       
  1048         //2) Rename from Filemanager.
       
  1049         //- HandleAttributeavailable - new title & new uri at same time.
       
  1050         //Check if media's uri(i.e 'aModifiedUri') is different from 'iUri'
       
  1051         //i.e media is Renamed then Refesh Media list.
       
  1052         TMPXAttribute uriAttrib(KMPXMediaGeneralUri);
       
  1053         TIdentityRelation<TMPXAttribute> match(&TMPXAttribute::Match);
       
  1054         TInt index = aAttributes.Find(uriAttrib, match);
       
  1055         if (KErrNotFound != index)
       
  1056             {
       
  1057             HBufC* modifiedUri = NULL;
       
  1058             TGlxMedia item = iItemMediaList->Item(0);
       
  1059             //Create the string convertor instance
       
  1060             CGlxUStringConverter* stringConverter =
       
  1061                     CGlxUStringConverter::NewL();
       
  1062             CleanupStack::PushL(stringConverter);
       
  1063 
       
  1064             //fetch media uri
       
  1065             stringConverter->AsStringL(item, aAttributes[index], 0,
       
  1066                     modifiedUri);
       
  1067             CleanupStack::PopAndDestroy(stringConverter);
       
  1068 
       
  1069             //Check if media item was renamed
       
  1070             if (modifiedUri && modifiedUri->Compare(*iUri) != 0)
       
  1071                 {
       
  1072                 //Set rename command as started since
       
  1073                 //Rename is also possible from File Manager
       
  1074                 iRenameStarted = ETrue;
       
  1075                 CleanupStack::PushL(modifiedUri);
       
  1076                 RefreshMediaListL(*modifiedUri);
       
  1077                 CleanupStack::PopAndDestroy(modifiedUri);
       
  1078                 }
       
  1079             }
       
  1080 
       
  1081         }
       
  1082 
       
  1083     TMPXAttribute titleAttrib(KMPXMediaGeneralTitle);
       
  1084     TIdentityRelation<TMPXAttribute> match(&TMPXAttribute::Match);
       
  1085 
       
  1086     if (KErrNotFound != aAttributes.Find(titleAttrib, match))
       
  1087         {
       
  1088         if (aList == iTagMediaList)
       
  1089             {
       
  1090             UpdateTagsL();
       
  1091             }
       
  1092         else if (aList == iAlbumMediaList)
       
  1093             {
       
  1094             UpdateAlbumsL();
       
  1095             }
       
  1096         }
       
  1097     }
       
  1098 
       
  1099 // ----------------------------------------------------------------------------
       
  1100 // HandleItemAddedL
       
  1101 // ----------------------------------------------------------------------------
       
  1102 // 
       
  1103 void CGlxMetadataContainer::HandleItemAddedL(TInt /*aStartIndex*/,
       
  1104         TInt /*aEndIndex*/, MGlxMediaList* aList)
       
  1105     {
       
  1106     TRACER("CGlxMetadataContainer::HandleItemAddedL()");
       
  1107 
       
  1108     if (!iTagMediaList)
       
  1109         {
       
  1110         CreateTagsMediaListL();
       
  1111         }
       
  1112     if (!iAlbumMediaList)
       
  1113         {
       
  1114         CreateAlbumsMediaListL();
       
  1115         }
       
  1116     if (!iMarquee)
       
  1117         {
       
  1118         EnableMarqueingL();
       
  1119         }
       
  1120     SetDurationLIicenseItemVisibilityL();
       
  1121     if (aList == iTagMediaList)
       
  1122         {
       
  1123         UpdateTagsL();
       
  1124         }
       
  1125     else if (aList == iAlbumMediaList)
       
  1126         {
       
  1127         UpdateAlbumsL();
       
  1128         }
       
  1129     if (aList == iItemMediaList)
       
  1130         {
       
  1131         if (iItemMediaList->Count())
       
  1132             {
       
  1133             TGlxMedia item = iItemMediaList->Item(0);
       
  1134             CGlxUStringConverter* stringConverter =
       
  1135                     CGlxUStringConverter::NewL();
       
  1136             CleanupStack::PushL(stringConverter);
       
  1137             for (TInt index = 0; index <= EDurationItem; index++)
       
  1138                 {
       
  1139                 HBufC* string = NULL;
       
  1140                 iTextSetter.Zero();
       
  1141 
       
  1142                 if (index == ESizeItem)
       
  1143                     {
       
  1144                     stringConverter->AsStringL(item, KMPXMediaGeneralSize, 0,
       
  1145                             string);
       
  1146                     }
       
  1147                 else if (index == EDurationItem)
       
  1148                     {
       
  1149                     stringConverter->AsStringL(item,
       
  1150                             KMPXMediaGeneralDuration, 0, string);
       
  1151                     }
       
  1152                 else if (index == ENameItem)
       
  1153                     {
       
  1154                     stringConverter->AsStringL(item, KMPXMediaGeneralTitle,
       
  1155                             0, string);
       
  1156                     }
       
  1157                 else if (index == EDateAndTimeItem)
       
  1158                     {
       
  1159                     stringConverter->AsStringL(item, KMPXMediaGeneralDate,
       
  1160                             R_QTN_DATE_USUAL_WITH_ZERO, string);
       
  1161                     }
       
  1162                 else if (index == EDescriptionItem)
       
  1163                     {
       
  1164                     stringConverter->AsStringL(item, KMPXMediaGeneralComment,
       
  1165                             0, string);
       
  1166                     }
       
  1167                 else if (index == ELocationItem)
       
  1168                     {
       
  1169                     stringConverter->AsStringL(item,
       
  1170                             KGlxMediaGeneralLocation, 0, string);
       
  1171                     }
       
  1172                 else if (index == EResolutionItem)
       
  1173                     {
       
  1174                     stringConverter->AsStringL(item,
       
  1175                             KGlxMediaGeneralDimensions, 0, string);
       
  1176                     }
       
  1177                 else if (index == ElicenseItem)
       
  1178                     {
       
  1179                     // If an item is DRM protected, License field in details
       
  1180                     // should display "View Details"
       
  1181                     string = StringLoader::LoadL(
       
  1182                             R_GLX_METADATA_VIEW_OPTIONS_VIEW);
       
  1183                     }
       
  1184                 else
       
  1185                     {
       
  1186                     //no implementation
       
  1187                     }
       
  1188                 if (string)
       
  1189                     {
       
  1190                     iTextSetter.Append(*string);
       
  1191                     }
       
  1192                 CleanupStack::PushL(string);
       
  1193                 EditItemL(index, EFalse);
       
  1194                 CleanupStack::PopAndDestroy(string);
       
  1195                 }
       
  1196             CleanupStack::PopAndDestroy(stringConverter);
       
  1197 
       
  1198             //Reopening Media list is completed
       
  1199             //& Rename Command is also completed
       
  1200             if (iRenameStarted)
       
  1201                 {
       
  1202                 iRenameStarted = EFalse;
       
  1203                 //reset Setting Items to undimmed status
       
  1204                 SetDimmed(iRenameStarted);
       
  1205                 iAvkonAppUi->ProcessCommandL(EGlxCmdRenameCompleted);
       
  1206                 }
       
  1207             }
       
  1208         }
       
  1209     }
       
  1210 // ----------------------------------------------------------------------------
       
  1211 // EnableMarqueingL
       
  1212 // ----------------------------------------------------------------------------
       
  1213 //  
       
  1214 void CGlxMetadataContainer::EnableMarqueingL()
       
  1215     {
       
  1216     TRACER("CGlxMetadataContainer::EnableMarqueingL()");
       
  1217     iMarquee = ETrue;
       
  1218     ListBox()->UseLogicalToVisualConversion(ETrue);
       
  1219     ListBox()->ItemDrawer()->ColumnData()->SetMarqueeParams(
       
  1220             KMarqueeLoopCount, KMarqueeScrollAmount, KMarqueeScrollDelay,
       
  1221             KMarqueeScrollInterval);
       
  1222     ListBox()->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
       
  1223 
       
  1224     //Fetch the current item index
       
  1225     TInt index = ListBox()->CurrentItemIndex();
       
  1226 
       
  1227     //Reset the disable marquee flag, so that marquee effect can continue (this is normally reset by 
       
  1228     //base class of glxmetaDatadialog::HandlePointerEventL()
       
  1229     ListBox()->ItemDrawer()->ClearFlags(CListItemDrawer::EDisableMarquee);
       
  1230 
       
  1231     //This is the function which actually starts marquee effect. It is anyway being called from base
       
  1232     //implementation of OfferKeyEventL(), but for pointer event, we have to call
       
  1233     //this function
       
  1234     ListBox()->DrawItem(index);
       
  1235     }
       
  1236 
       
  1237 // ----------------------------------------------------------------------------
       
  1238 // HandleCommandCompleteL
       
  1239 // ----------------------------------------------------------------------------
       
  1240 // 
       
  1241 void CGlxMetadataContainer::HandleCommandCompleteL(TAny* aSessionId,
       
  1242         CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList)
       
  1243     {
       
  1244     TRACER("CGlxMetadataContainer::HandleCommandCompleteL()");
       
  1245 
       
  1246     //Callback from MDS when rename the Title
       
  1247     if (aError == KErrNone)
       
  1248         {
       
  1249         if (aList == iItemMediaList && aCommandResult->IsSupported(
       
  1250                 KMPXMediaGeneralTitle))
       
  1251             {
       
  1252             GLX_LOG_INFO("RenameCMD to MDS completed");
       
  1253             //Since RenameCommand to MDS is redundant and FileSystem has 
       
  1254             //already renamed the file, so there is no need to do anything here
       
  1255             }
       
  1256         }
       
  1257 
       
  1258     //To update the location information once the delete operation is successful.
       
  1259     if (aList == iItemMediaList && iLocationinfo && static_cast<TAny*> (this)
       
  1260             == aSessionId)
       
  1261         {
       
  1262         TGlxMedia media = iItemMediaList->Item(0);
       
  1263         media.DeleteLocationAttribute();
       
  1264         iLocationinfo = EFalse;
       
  1265         if (aError == KErrNone)
       
  1266             {
       
  1267             iTextSetter.Zero();
       
  1268             EditItemL(ELocationItem, EFalse);
       
  1269             }
       
  1270         }
       
  1271     }
       
  1272 
       
  1273 // ----------------------------------------------------------------------------
       
  1274 // HandleItemRemovedL
       
  1275 // ----------------------------------------------------------------------------
       
  1276 //  
       
  1277 void CGlxMetadataContainer::HandleItemRemovedL(TInt /*aStartIndex*/,
       
  1278         TInt /*aEndIndex*/, MGlxMediaList* /*aList*/)
       
  1279     {
       
  1280     TRACER("CGlxMetadataContainer::HandleItemRemovedL()");
       
  1281     if (iItemMediaList->Count() == 0)
       
  1282         {
       
  1283         iDialogObesrver.HandleItemRemovedL();
       
  1284         }
       
  1285     }
       
  1286 
       
  1287 // ----------------------------------------------------------------------------
       
  1288 // HandleFocusChangedL
       
  1289 // ----------------------------------------------------------------------------
       
  1290 //  
       
  1291 void CGlxMetadataContainer::HandleFocusChangedL(
       
  1292         NGlxListDefs::TFocusChangeType /*aType*/, TInt /*aNewIndex*/,
       
  1293         TInt /*aOldIndex*/, MGlxMediaList* /*aList*/)
       
  1294     {
       
  1295     TRACER("CGlxMetadataContainer::HandleFocusChangedL()");
       
  1296     }
       
  1297 
       
  1298 // ----------------------------------------------------------------------------
       
  1299 // HandleItemSelectedL
       
  1300 // ----------------------------------------------------------------------------
       
  1301 //  
       
  1302 void CGlxMetadataContainer::HandleItemSelectedL(TInt /*aIndex*/,
       
  1303         TBool /*aSelected*/, MGlxMediaList* /*aList*/)
       
  1304     {
       
  1305     TRACER("CGlxMetadataContainer::HandleItemSelectedL");
       
  1306     }
       
  1307 
       
  1308 // ----------------------------------------------------------------------------
       
  1309 // HandleMessageL
       
  1310 // ----------------------------------------------------------------------------
       
  1311 //    
       
  1312 void CGlxMetadataContainer::HandleMessageL(const CMPXMessage& /*aMessage*/,
       
  1313         MGlxMediaList* /*aList*/)
       
  1314     {
       
  1315     TRACER("CGlxMetadataContainer::HandleMessageL()");
       
  1316     }
       
  1317 
       
  1318 // ----------------------------------------------------------------------------
       
  1319 // HandleError
       
  1320 // ----------------------------------------------------------------------------
       
  1321 //
       
  1322 void CGlxMetadataContainer::HandleError(TInt /*aError*/)
       
  1323     {
       
  1324     TRACER("CGlxMetadataContainer::HandleError()");
       
  1325     TRAP_IGNORE(HandleErrorL());
       
  1326     }
       
  1327 
       
  1328 // ----------------------------------------------------------------------------
       
  1329 // HandleErrorL
       
  1330 // ----------------------------------------------------------------------------
       
  1331 //
       
  1332 void CGlxMetadataContainer::HandleErrorL()
       
  1333     {
       
  1334     TRACER("CGlxMetadataContainer::HandleErrorL()");
       
  1335     }
       
  1336 
       
  1337 // ----------------------------------------------------------------------------
       
  1338 // HandleCommandCompleteL
       
  1339 // ----------------------------------------------------------------------------
       
  1340 //  
       
  1341 void CGlxMetadataContainer::HandleCommandCompleteL(
       
  1342         CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/)
       
  1343     {
       
  1344     TRACER("CGlxMetadataContainer::HandleCommandCompleteL()");
       
  1345     }
       
  1346 
       
  1347 // ----------------------------------------------------------------------------
       
  1348 // HandleMediaL
       
  1349 // ----------------------------------------------------------------------------
       
  1350 //  
       
  1351 void CGlxMetadataContainer::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/)
       
  1352     {
       
  1353     TRACER("CGlxMetadataContainer::HandleMediaL()");
       
  1354     }
       
  1355 
       
  1356 // ----------------------------------------------------------------------------
       
  1357 // HandleItemModifiedL
       
  1358 // ----------------------------------------------------------------------------
       
  1359 //  
       
  1360 void CGlxMetadataContainer::HandleItemModifiedL(
       
  1361         const RArray<TInt>& /*aItemIndexes*/, MGlxMediaList* /*aList*/)
       
  1362     {
       
  1363     TRACER("CGlxMetadataContainer::HandleItemModifiedL()");
       
  1364     }
       
  1365 
       
  1366 // ----------------------------------------------------------------------------
       
  1367 // ChangeMskL
       
  1368 // ----------------------------------------------------------------------------
       
  1369 //     
       
  1370 void CGlxMetadataContainer::ChangeMskL()
       
  1371     {
       
  1372     TRACER("CGlxMetadataContainer::ChangeMskL()");
       
  1373     CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL();
       
  1374     CleanupClosePushL(*uiUtility);
       
  1375     switch (ListBox()->CurrentItemIndex())
       
  1376         {
       
  1377         case ENameItem:
       
  1378         case EDescriptionItem:
       
  1379         case ETagsItem:
       
  1380         case EAlbumsItem:
       
  1381             {
       
  1382             uiUtility->ScreenFurniture()->ModifySoftkeyIdL(
       
  1383                     CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
  1384                     EAknSoftkeyEdit, R_GLX_METADATA_MSK_EDIT);
       
  1385             }
       
  1386             break;
       
  1387         case EDateAndTimeItem:
       
  1388         case ELocationItem:
       
  1389         case ESizeItem:
       
  1390         case EDurationItem:
       
  1391         case ElicenseItem:
       
  1392         case EResolutionItem:
       
  1393             {
       
  1394             uiUtility->ScreenFurniture()->ModifySoftkeyIdL(
       
  1395                     CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
  1396                     EAknSoftkeyEdit, R_GLX_METADATA_MSK_BLANK);
       
  1397             }
       
  1398             break;
       
  1399         default:
       
  1400             {
       
  1401             break;
       
  1402             }
       
  1403         }
       
  1404 
       
  1405     CleanupStack::PopAndDestroy(uiUtility);
       
  1406     }
       
  1407 
       
  1408 // ---------------------------------------------------------------------------
       
  1409 // Parse the drive, path & extension from the old uri,
       
  1410 // And return the modified uri by appending the new title
       
  1411 // ---------------------------------------------------------------------------
       
  1412 TFileName CGlxMetadataContainer::ParseFileName(const TDesC& aTitleText)
       
  1413     {
       
  1414     TRACER("CGlxMetadataContainer::ParseFileName()");
       
  1415     const TGlxMedia& media = iItemMediaList->Item(0);
       
  1416     TParsePtrC parsePtr(media.Uri());
       
  1417 
       
  1418     TFileName destinationFileName;
       
  1419     destinationFileName.Append(parsePtr.DriveAndPath());
       
  1420     destinationFileName.Append(aTitleText);
       
  1421     destinationFileName.Append(parsePtr.Ext());
       
  1422 
       
  1423     return destinationFileName;
       
  1424     }
       
  1425 
       
  1426 // ---------------------------------------------------------------------------
       
  1427 // Refresh MediaList with modified FileName.
       
  1428 // ---------------------------------------------------------------------------
       
  1429 void CGlxMetadataContainer::RefreshMediaListL(const TDesC& aModifiedUri)
       
  1430     {
       
  1431     //Refresh media list since media is renamed
       
  1432     TRACER("CGlxMetadataContainer::RefreshMediaListL()");
       
  1433     GLX_LOG_URI("CGlxMetadataContainer::RefreshMediaListL(%S)", &aModifiedUri);
       
  1434     if (iUri)
       
  1435         {
       
  1436         delete iUri;
       
  1437         iUri = NULL;
       
  1438         }
       
  1439     //always points to current media name
       
  1440     iUri = aModifiedUri.AllocL();
       
  1441     CMPXFilter* filter = TGlxFilterFactory::CreateURIFilterL(*iUri);
       
  1442     CleanupStack::PushL(filter);
       
  1443 
       
  1444     //Update media list's filter
       
  1445     iItemMediaList->SetFilterL(filter);
       
  1446     CleanupStack::PopAndDestroy(filter);
       
  1447     }
       
  1448 
       
  1449 //End of file