photosgallery/viewframework/commandhandlers/commoncommandhandlers/inc/glxcommandhandlernewmedia.h
changeset 0 4e91876724a2
child 25 191387a8b767
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:    Add to container commmand handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __C_GLXCOMMANDHANDLERNEWMEDIA_H__
       
    22 #define __C_GLXCOMMANDHANDLERNEWMEDIA_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <glxmediaid.h>
       
    26 #include <glxmpxcommandcommandhandler.h>
       
    27 
       
    28 class CEikAppUi;
       
    29 
       
    30 class MGlxMediaListProvider;
       
    31 
       
    32 /**
       
    33  * Command handler for adding new media (new containers)
       
    34  * @author Alex Birkett
       
    35  *
       
    36  * @internal reviewed 06/06/2007 by Dave Schofield
       
    37  */
       
    38 NONSHARABLE_CLASS(CGlxCommandHandlerNewMedia) : public CGlxMpxCommandCommandHandler
       
    39 	{
       
    40 public:
       
    41     /** 
       
    42      * Two-phase constructor: 
       
    43      * @param aMediaListProvider object that provides the media list.
       
    44      */
       
    45 	IMPORT_C static CGlxCommandHandlerNewMedia* NewL(MGlxMediaListProvider* aMediaListProvider);
       
    46     
       
    47 	/** Destructor */
       
    48 	IMPORT_C ~CGlxCommandHandlerNewMedia();
       
    49 
       
    50 	/**
       
    51 	 * Execute the dialog.
       
    52 	 * @param aNewMediaId
       
    53 	 *        The ID of the media that is created
       
    54 	 * @return system wide error code.
       
    55 	 *        (KErrCancel if the dialog is cancelled).
       
    56 	 */
       
    57 	IMPORT_C TInt ExecuteLD(TGlxMediaId& aNewMediaId);
       
    58 	
       
    59 public: // from CGlxMpxCommandCommandHandler
       
    60 
       
    61 	/** See @ref CGlxMpxCommandCommandHandler::DoHandleCommandCompleteL */
       
    62 	void DoHandleCommandCompleteL(TAny* aSessionId, CMPXCommand* aCommandResult, 
       
    63             TInt aError, MGlxMediaList* aList);
       
    64 		
       
    65 	/** See @ref CGlxMpxCommandCommandHandler::OkToExit */
       
    66 	TBool OkToExit() const;
       
    67     
       
    68 	/** See @ref CGlxMpxCommandCommandHandler::CreateCommandL */
       
    69 	virtual CMPXCommand* CreateCommandL(TInt aCommandId, MGlxMediaList& aList,
       
    70 	    TBool& aConsume) const;    
       
    71 	
       
    72 	/** See @ref CGlxMpxCommandCommandHandler::HandleErrorL */
       
    73 	void HandleErrorL(TInt aError);
       
    74 
       
    75 public: // from CGlxMediaListCommandHandler
       
    76 	/** See @ref CGlxMediaListCommandHandler::BypassFiltersForExecute */
       
    77 	IMPORT_C TBool BypassFiltersForExecute() const;
       
    78 	
       
    79 private:
       
    80     /** Second phase constructor */
       
    81 	void ConstructL();
       
    82 	
       
    83     /** 
       
    84      * First phase constructor 
       
    85      * @param aMediaListOwner object that provides the media list. 
       
    86      */
       
    87 	
       
    88 	CGlxCommandHandlerNewMedia(MGlxMediaListProvider* aMediaListProvider);
       
    89     
       
    90 	/**
       
    91      * Fetches the 'media popup title' and 'default new media item title'
       
    92      * from the collection.
       
    93      * @param aCollectionId Collection plugin id from which to fetch titles.
       
    94      * @param aDefaultNewMediaItemTitle On return contains the default new media item title.
       
    95      */
       
    96 	void TitlesL(const TGlxMediaId aCollectionId, TDes& aDefaultNewMediaItemTitle) const;
       
    97 	
       
    98     /**
       
    99      * Generates a unique new media item title based on the titles of items that already exist.
       
   100      * @param aDefaultNewMediaItemTitle the default new media item title (e.g.) "New Tag"
       
   101      * @param aList a media list containing the existing media e.g. "New Tag", "New Tag (1)"
       
   102      * @return The new media item title e.g. "New Tag (2)"
       
   103      */
       
   104 	HBufC* GenerateNewMediaItemTitleL(const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const;
       
   105 
       
   106     /**
       
   107      * Sets the media list focus
       
   108      * and tries to exit the dialog.
       
   109      * @param aIndex. Index of the item in the media list to focus.
       
   110      */
       
   111     void SetFocusL(TInt aIndex);
       
   112     
       
   113 protected: // From MGlxMediaListObserver    
       
   114     /// See @ref MGlxMediaListObserver::HandleItemAddedL
       
   115     IMPORT_C void HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList);
       
   116 
       
   117 private:
       
   118     /**
       
   119      * CGlxAsyncFocuser
       
   120      * Used by CGlxCommandHandlerNewMedia to perform focusing operations
       
   121      * asynchronously.
       
   122      */ 
       
   123     NONSHARABLE_CLASS(CGlxAsyncFocuser)
       
   124         : public CActive
       
   125         {
       
   126         public:            
       
   127             /**
       
   128              * Constructor
       
   129              * @param aGlxCommandHandlerNewMedia object on which to call SetFocusL
       
   130              */
       
   131             CGlxAsyncFocuser(CGlxCommandHandlerNewMedia* aGlxCommandHandlerNewMedia);      
       
   132             
       
   133             /**
       
   134              * Destructor
       
   135              */
       
   136             ~CGlxAsyncFocuser();
       
   137 
       
   138         public:
       
   139             /**
       
   140              * Calls CGlxCommandHandlerNewMedia::SetFocusL asynchronously
       
   141              * i.e from CGlxAsyncFocuser::RunL()
       
   142              * @param aIndex index to pass to 
       
   143              */
       
   144             void SetFocus(TInt aIndex);
       
   145         
       
   146         public: // from CActive
       
   147             /** See @ref CActive::RunL */
       
   148             void RunL();
       
   149             
       
   150             /** See @ref CActive::DoCancel */
       
   151             void DoCancel();
       
   152         
       
   153         private:
       
   154             /**
       
   155              * Object on which to call SetFocusL (not owned)
       
   156              */
       
   157             CGlxCommandHandlerNewMedia* iGlxCommandHandlerNewMedia;
       
   158             
       
   159             /**
       
   160              * Index of the item to be focused.
       
   161              */
       
   162             TInt iFocusIndex;  
       
   163         };
       
   164    
       
   165 private:    
       
   166     /**
       
   167      * Resource offset
       
   168      */
       
   169     TInt iResourceOffset;
       
   170     
       
   171     /**
       
   172      *  Id of new media
       
   173      */
       
   174     TGlxMediaId iNewMediaId;
       
   175     
       
   176     /**
       
   177      *  Active scheduler wait object. (Owned)
       
   178      */
       
   179     CActiveSchedulerWait* iSchedulerWait;
       
   180     
       
   181     /**
       
   182      * Error set by DoHandleCommandCompleteL()
       
   183      */
       
   184     mutable TInt iNewMediaCreationError;
       
   185     
       
   186     /**
       
   187      * Ok to exit. ETrue if OK to exit else EFalse.
       
   188      */
       
   189     mutable TBool iOkToExit;
       
   190     
       
   191     /**
       
   192      * Object used to call SetFocusL asynchronously (owned)
       
   193      */
       
   194     CGlxAsyncFocuser* iAsyncFocuser;
       
   195     
       
   196     /**
       
   197      * The title of the new media item.
       
   198      */
       
   199     mutable HBufC* iNewMediaItemTitle;
       
   200 
       
   201     /**
       
   202 	 * ETrue if a file with the same name already exists, else EFalse
       
   203      */
       
   204     mutable TBool iFileNameAlreadyExists ;
       
   205 	};
       
   206 
       
   207 #endif // __C_GLXCOMMANDHANDLERNEWMEDIA_H__