mmappcomponents/harvester/collectionmediator/inc/mpxmoveitemhelper.h
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Class to help with moving items between collections
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXMOVEITEMHELPER_H
       
    20 #define CMPXMOVEITEMHELPER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <mpxcollectionobserver.h>
       
    24 
       
    25 class CMPXMedia;
       
    26 class MMPXCollectionUtility;
       
    27 class MMPXMoveItemObserver;
       
    28 
       
    29 /**
       
    30  *  Class to help move items between collections
       
    31  *
       
    32  *  @lib mpxcollectionmediator.lib
       
    33  *  @since S60 3.0
       
    34  */
       
    35 class CMPXMoveItemHelper  : public CBase,
       
    36                             public MMPXCollectionFindObserver
       
    37     {
       
    38 
       
    39 public:
       
    40 
       
    41     /**
       
    42     * Two-phase constructor
       
    43     * @param aObs observer to the move item helper
       
    44     */
       
    45     IMPORT_C static CMPXMoveItemHelper* NewL( MMPXMoveItemObserver* aObs );
       
    46 
       
    47     /**
       
    48     * Two-phase construcotr
       
    49     * @param aObs observer to the move item helper
       
    50     */
       
    51     IMPORT_C static CMPXMoveItemHelper* NewLC( MMPXMoveItemObserver* aObs );
       
    52 
       
    53     /**
       
    54     * Virtual destructor
       
    55     */
       
    56     virtual ~CMPXMoveItemHelper();
       
    57 
       
    58 public: // New Functions
       
    59     
       
    60     /**
       
    61     * Move an item from one collection to another, asynchronous
       
    62     * @param aMedia Source item, must contain item id or uri and original collection
       
    63     * @param aNewCollection Destinaton collection to move the item to
       
    64     */
       
    65     IMPORT_C void MoveItemL( CMPXMedia& aMedia, TUid aNewCollection );
       
    66 
       
    67     /**
       
    68     * Gets the full details of an item then
       
    69     * move an item from one collection to another, asynchronous
       
    70     * @param aMedia Source item, must contain item id or uri and original collection
       
    71     * @param aNewCollection Destinaton collection to move the item to
       
    72     */
       
    73     IMPORT_C void FetchAndMoveItemL( const CMPXMedia& aMedia, TUid aNewCollection );
       
    74     
       
    75     /**
       
    76     * Gets the full details of an item then
       
    77     * move an item from one collection to another, synchronous
       
    78     * @param aMedia Source item, must contain item id or uri and original collection
       
    79     * @param aNewCollection Destinaton collection to move the item to
       
    80     */
       
    81     IMPORT_C void FetchAndMoveItemSyncL( const CMPXMedia& aMedia, TUid aNewCollection );   
       
    82 
       
    83 private: // New functions
       
    84 
       
    85     /**
       
    86     * Updates a media with any special move requirements
       
    87     * ie: move from podcast -> music will set genre to "unknown"
       
    88     * @param aMedia, media to update
       
    89     * @param aOldCollection, old collection
       
    90     * @param aNewCollection, new collection
       
    91     */
       
    92     void UpdateMediaForMoveL( CMPXMedia& aMedia, 
       
    93                               TUid& aOldCollection,
       
    94                               TUid& aNewCollection );
       
    95     
       
    96     /**
       
    97     * Handles the completion of a FindAllL() 
       
    98     * @param aResult result of the find
       
    99     */
       
   100     void DoHandleFindAllL( const CMPXMedia& aResult );
       
   101     
       
   102     /**
       
   103     * Add an item to a collection
       
   104     * @param aMedia, media to add
       
   105     * @param aCollectionId, collection UID
       
   106     */
       
   107     void DoAddL( CMPXMedia* aMedia, TUid aCollectionId );
       
   108     
       
   109     /**
       
   110     * Remove an item to a collection
       
   111     * @param aMedia, media to add
       
   112     * @param aCollectionId, collection UID
       
   113     */
       
   114     void DoRemoveL( CMPXMedia* aMedia, TUid aCollectionId );
       
   115     
       
   116 protected:
       
   117      
       
   118      /**
       
   119      * From MMPXCollectionFindObserver
       
   120      */
       
   121      void HandleFindAllL(const CMPXMedia& aResults,
       
   122                          TBool aComplete,TInt aError);
       
   123 
       
   124 private: 
       
   125     /* State representation for the move event */
       
   126     enum TMoveState
       
   127         {
       
   128         EIdle, // Not moving
       
   129         EFind  // Fetching full details
       
   130         };
       
   131                 
       
   132 private:
       
   133 
       
   134     /**
       
   135     * Private constructor
       
   136     * @param aObs observer to the move helper
       
   137     */
       
   138     CMPXMoveItemHelper( MMPXMoveItemObserver* aObs );
       
   139 
       
   140     /**
       
   141     * 2nd phase constructor
       
   142     */
       
   143     void ConstructL();
       
   144 
       
   145 private: // data
       
   146     MMPXMoveItemObserver* iObs;
       
   147     MMPXCollectionUtility* iCollection;
       
   148     
       
   149     // Cache the async state
       
   150     TMoveState iMoveState;
       
   151     TUid       iMoveTarget;
       
   152     TUid       iMusicCollectionID;   // Music Collection ID
       
   153     TUid       iPodCastCollectionID; // PodCast Collection ID
       
   154     };
       
   155 
       
   156 #endif // CMPXMOVEITEMHELPER_H