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