photosgallery/controllers/fetcher/src/glxfetcher.cpp
changeset 0 4e91876724a2
child 57 ea65f74e6de4
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:    provide synchronized access to file systema and metadata source
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <aknViewAppUi.h>				// CAknViewAppUi 
       
    22 #include <avkon.rsg>
       
    23 #include <data_caging_path_literals.hrh>		// KDC_APP_RESOURCE_DIR			
       
    24 #include <eikapp.h>						// CEikApplication 
       
    25 #include <glxfetcherdialog.rsg>           // FOR GETTING VIEW ID AND RESOURCE ID
       
    26 #include <glxcollectionpluginall.hrh>	// All item collection plugin id
       
    27 #include <glxlog.h> 					// Logging macros
       
    28 #include <glxresourceutilities.h>       // for CGlxResourceUtilities
       
    29 #include <glxcommandhandlerhelp.h>
       
    30 #include <mglxmedialist.h>				// MGlxMediaList, CMPXCollectionPath
       
    31 
       
    32 #include "glxfetcher.hrh"				// For implementation id
       
    33 #include "glxfetcherdialog.h"           // CGlxFetcherDialog
       
    34 #include "glxfetcher.h"                 // CGlxFetcher
       
    35 #include "glxtracer.h"
       
    36 #include "glxlog.h"
       
    37 
       
    38 _LIT(KFetcherGridViewResource,"glxfetcherdialog.rsc"); //FetcherGridDialog Resource File
       
    39     
       
    40 // ---------------------------------------------------------------------------
       
    41 // Two-phased constructor.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CGlxFetcher* CGlxFetcher::NewL()
       
    45     {
       
    46     TRACER("CGlxFetcher::NewL");
       
    47     CGlxFetcher* self = new( ELeave ) CGlxFetcher();
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CGlxFetcher::ConstructL()
       
    59     {
       
    60     TRACER("CGlxFetcher::ConstructL");
       
    61     // No implementation required
       
    62     }
       
    63     
       
    64 // ---------------------------------------------------------------------------
       
    65 // C++ default constructor can NOT contain any code, that might leave.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CGlxFetcher::CGlxFetcher()
       
    69     {
       
    70     TRACER("CGlxFetcher::CGlxFetcher");
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Destructor
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CGlxFetcher::~CGlxFetcher()
       
    78     {
       
    79     TRACER("CGlxFetcher::~CGlxFetcher");
       
    80 
       
    81     if ( iResourceOffset )
       
    82         {
       
    83         CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
       
    84         }
       
    85 	if(iDialog)
       
    86 		{
       
    87 		iDialog = NULL;
       
    88 		}
       
    89     delete iSelectionSoftkey;
       
    90     delete iTitle;
       
    91     
       
    92     }
       
    93     
       
    94 // ---------------------------------------------------------------------------
       
    95 // SetMultiSelectionL
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CGlxFetcher::SetMultiSelectionL( TBool aMultiSelect )
       
    99     {
       
   100     TRACER("CGlxFetcher::SetMultiSelectionL");
       
   101     iIsMultiSelection = aMultiSelect;
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // SetMimeTypesL
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CGlxFetcher::SetMimeTypesL( const MDesCArray& /*aMimeTypes*/ )
       
   109     {
       
   110     TRACER("CGlxFetcher::SetMimeTypesL (not supported)");
       
   111     // No implementation required (not supported)
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // SetSelectionSoftkeyL
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CGlxFetcher::SetSelectionSoftkeyL( const TDesC& aSelectionSoftkey )
       
   119     {
       
   120     TRACER("CGlxFetcher::SetSelectionSoftkeyL");
       
   121 	
       
   122 	HBufC* tmp = aSelectionSoftkey.AllocL();
       
   123 	delete iSelectionSoftkey;
       
   124 	iSelectionSoftkey = tmp;
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // SetHeadingL
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CGlxFetcher::SetHeadingL( const TDesC& aTitle )
       
   132     {
       
   133     TRACER("CGlxFetcher::SetHeadingL");
       
   134 	
       
   135 	HBufC* tmp = aTitle.AllocL();
       
   136 	delete iTitle;
       
   137 	iTitle = tmp;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // SetVerifierL
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 void CGlxFetcher::SetVerifierL( MMGFetchVerifier& aVerifier )
       
   145     {
       
   146     TRACER("CGlxFetcher::SetVerifierL");
       
   147 
       
   148 	iVerifier = &aVerifier;
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // GetCancelerL
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void CGlxFetcher::GetCancelerL( MMGFetchCanceler*& aCanceler )
       
   156     {
       
   157     TRACER("CGlxFetcher::GetCancelerL");
       
   158 	
       
   159 	aCanceler = this;
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // LaunchL
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 TBool CGlxFetcher::LaunchL( CDesCArray& aSelectedFiles,
       
   168                             TMediaFileType aMediaType )
       
   169    	{
       
   170    	TRACER("CGlxFetcher::LaunchL");
       
   171 	TInt buttonId;
       
   172     TFileName resFile;
       
   173     TParse parse;
       
   174     parse.Set(KFetcherGridViewResource, &KDC_APP_RESOURCE_DIR, NULL);
       
   175 
       
   176     resFile.Append(parse.FullName()); 
       
   177     CGlxResourceUtilities::GetResourceFilenameL(resFile);
       
   178     iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resFile);
       
   179 	
       
   180 	// Configure heading and filter type
       
   181 	switch ( aMediaType )
       
   182 	    {
       
   183 	    case EImageFile:
       
   184 	        {
       
   185             iTitle = TitleForImageFetcherL();
       
   186             iFilterType = EGlxFilterImage;
       
   187             break;
       
   188 	        }
       
   189 	    case EVideoFile:
       
   190 	        {
       
   191             iTitle = TitleForVideoFetcherL();
       
   192             iFilterType = EGlxFilterVideo;
       
   193             break;
       
   194 	        }
       
   195 	    default:
       
   196 	        {
       
   197             GLX_LOG_INFO("CGlxFetcher::LaunchL  - Error: Unsupported media type, Leaving");
       
   198             User::Leave( KErrNotSupported );
       
   199 	        }
       
   200 	    }
       
   201 	// create the dialog first
       
   202 	iDialog =
       
   203 	    CGlxFetcherDialog::NewL( aSelectedFiles, iVerifier ,iFilterType ,*iTitle, iIsMultiSelection );
       
   204 	// Returns zero when Fetcher is cancelled by User.
       
   205 	
       
   206 	if( iIsMultiSelection )
       
   207 		{
       
   208 		buttonId = iDialog->ExecuteLD( R_MODAL_MULTI_DIALOG );
       
   209 		}
       
   210 	else
       
   211 		{
       
   212 		buttonId = iDialog->ExecuteLD( R_MODAL_SINGLE_DIALOG );	
       
   213 		}
       
   214     // Return false if the fetcher was canceled by user
       
   215 	return ( 0 != buttonId && aSelectedFiles.Count()!=0);
       
   216   	}
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // Return Dialog title
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 HBufC* CGlxFetcher::TitleForImageFetcherL() const
       
   223     {
       
   224     TRACER("CGlxFetcher::TitleForImageFetcherL()");
       
   225     return TitleL( R_FETCHER_DIALOG_TITLE_IMAGE, R_FETCHER_DIALOG_TITLE_IMAGES );
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // Return Dialog title
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 HBufC* CGlxFetcher::TitleForVideoFetcherL() const
       
   233     {
       
   234     TRACER("CGlxFetcher::TitleForVideoFetcherL()");
       
   235     return TitleL( R_FETCHER_DIALOG_TITLE_VIDEO, R_FETCHER_DIALOG_TITLE_VIDEOS );
       
   236     } 
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // Return Dialog title
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 HBufC* CGlxFetcher::TitleL( TInt aSingleSelectionTitleResourceId, 
       
   243         TInt aMultiSelectionTitleResourceId ) const
       
   244     {
       
   245     TRACER("CGlxFetcher::TitleL()");
       
   246     if( !iTitle )
       
   247         {
       
   248         TInt resourceId = aSingleSelectionTitleResourceId;
       
   249         if ( iIsMultiSelection )	
       
   250             {
       
   251             resourceId = aMultiSelectionTitleResourceId;
       
   252             }
       
   253         return CCoeEnv::Static()->AllocReadResourceL( resourceId );
       
   254         }
       
   255     return iTitle;
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // From MMGFetchCanceler
       
   260 // -----------------------------------------------------------------------------
       
   261 //	
       
   262 void CGlxFetcher::CancelFetcherL()
       
   263     {
       
   264     TRACER("CGlxFetcher::CancelFetcherL");
       
   265 	//pass EAknCmdExit  as parameter to exit the fetcher dialog
       
   266 	if(iDialog)
       
   267 		{
       
   268 		iDialog->CallCancelFetcherL(EAknCmdExit );	
       
   269 		}
       
   270 	}