homesync/contentmanager/cmserver/cmfillmanager/inc/cmfmmain.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Main class in the Fill manager component
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CMFMMAIN_H
       
    20 #define C_CMFMMAIN_H
       
    21 
       
    22 #include <f32file.h>
       
    23 #include "cmfmfillruleobserver.h"
       
    24 #include "cmfmupnpactionobserver.h"
       
    25 #include "cmfmtransferobserver.h"
       
    26 #include "cmfmitemhandlerobserver.h"
       
    27 #include "cmmmobserver.h"        
       
    28 #include "cmcommon.h"
       
    29 #include "cmfillmanager.h"
       
    30    
       
    31 /* Forward declarations. */
       
    32 class CCmFmUpnpMngr;
       
    33 class MCmServiceObserver;
       
    34 class CCmFmFillDriveMngr;
       
    35 class CCmFmFillRuleFilledDataMngr;
       
    36 class CCmFmDuplicateDetector;
       
    37 class CCmMmMain;
       
    38 class CCmDmMain;
       
    39 class CCmFmDownloadProxy;
       
    40 class CCmFillListItem;
       
    41 class CUpnpAVDeviceList;
       
    42 class CCmDriveInfo;
       
    43 class CMdESession;
       
    44 class CCmFmMpxNotifier;
       
    45 class CCmFmGlxNotifier;
       
    46 
       
    47 // Constants
       
    48 _LIT( KCmFmFillManager, "FillManager");
       
    49 
       
    50 /**
       
    51  *  CCmFmMain class 
       
    52  *  Part of Fill manager.Fill service
       
    53  *
       
    54  *  @lib cmfillmanager.lib
       
    55  *
       
    56  *  @since S60 v3.1
       
    57  */
       
    58 class CCmFmMain : public CActive,
       
    59                   public MCmFmManager, 
       
    60                   public MCmFmFillRuleObserver,
       
    61                   public MCmFmUPnPActionObserver, 
       
    62                   public MCmFmTransferObserver,
       
    63                   public MCmFmItemHandlerObserver, 
       
    64                   public MCmMmObserver
       
    65     {     
       
    66     
       
    67 public:
       
    68 
       
    69     /**
       
    70      * Two-phased constructor.
       
    71      *
       
    72      * @since S60 5.1
       
    73      * @param aObserver, service observer
       
    74      * @param aSession, mde session
       
    75      * @param aDBManager, database manager
       
    76      * @param aMemManager, memory manager
       
    77      * @return  pointer to CCmFmMain class
       
    78      */
       
    79     static CCmFmMain* NewL(
       
    80         MCmServiceObserver* aObserver, CMdESession& aSession,
       
    81         CCmDmMain* aDBManager, CCmMmMain* aMemManager );
       
    82 
       
    83     /**
       
    84      * Two-phased constructor.
       
    85      *
       
    86      * @since S60 5.1
       
    87      * @param aObserver, service observer
       
    88      * @param aSession, mde session
       
    89      * @param aDBManager, database manager
       
    90      * @param aMemManager, memory manager
       
    91      * @return  pointer to CCmFmMain class
       
    92      */
       
    93     static CCmFmMain* NewLC(
       
    94         MCmServiceObserver* aObserver, CMdESession& aSession,
       
    95         CCmDmMain* aDBManager, CCmMmMain* aMemManager );
       
    96 
       
    97     /**
       
    98      * Destructor.
       
    99      */
       
   100     virtual ~CCmFmMain();
       
   101 
       
   102     /**
       
   103      * Sort function that arranges pointers by id
       
   104      * @since S60 5.1
       
   105      * @param aItem1, item to be sorted
       
   106      * @param aItem2, item to be sorted
       
   107      */
       
   108     static TInt CompareById( const CCmFillListItem& aItem1,
       
   109                              const CCmFillListItem& aItem2 );
       
   110 
       
   111     /**
       
   112      * Sort function that arranges pointers by size
       
   113      * @since S60 3.2
       
   114      * @param aItem1, item to be sorted
       
   115      * @param aItem2, item to be sorted
       
   116      */
       
   117     static TInt CompareBySize( const CCmFillListItem& aItem1,
       
   118                                const CCmFillListItem& aItem2 );
       
   119 
       
   120 
       
   121 protected:
       
   122 
       
   123 // From base class MCmFmManager
       
   124     
       
   125     /**
       
   126      * From MCmFmManager
       
   127      * See base class definition
       
   128      */
       
   129     void StartFillL();
       
   130 
       
   131     /**
       
   132      * From MCmFmManager
       
   133      * See base class definition
       
   134      */
       
   135     void CancelOperation();
       
   136 
       
   137     /**
       
   138      * From MCmFmManager
       
   139      * See base class definition
       
   140      */
       
   141     void PreProcessListsL();
       
   142 
       
   143     /**
       
   144      * From MCmFmManager
       
   145      * See base class definition
       
   146      */
       
   147     void PreProcessListL( const TDesC8& aFillListName );
       
   148 
       
   149     /**
       
   150      * From MCmFmManager
       
   151      * See base class definition
       
   152      */
       
   153     void GetColItemsL( TCmMetadataField aType, 
       
   154         TCmMediaType aMedia, CDesCArray& aArray );
       
   155 
       
   156     /**
       
   157      * From MCmFmManager
       
   158      * See base class definition
       
   159      */
       
   160     void GetColItemsL( TCmMetadataField aType, 
       
   161                        TCmMediaType aMedia,
       
   162                        CCmSqlPropertyContainer& aPropertys );
       
   163 
       
   164     /**
       
   165      * From MCmFmManager
       
   166      * See base class definition
       
   167      */
       
   168     void GetMetadataItemsL( CCmSqlPropertyCollector& aPropertys );
       
   169 
       
   170     /**
       
   171      * From MCmFmManager
       
   172      * See base class definition
       
   173      */   
       
   174     void SetAvController( MUPnPAVController* aAVController ); 
       
   175 
       
   176     /**
       
   177      * From MCmFmManager
       
   178      * See base class definition
       
   179      */   
       
   180     void UpdatePriorities();
       
   181 
       
   182     /**
       
   183      * From MCmFmManager
       
   184      * See base class definition
       
   185      */
       
   186     void UpdateRefIds();
       
   187 
       
   188     /**
       
   189      * From MCmFmManager
       
   190      * See base class definition
       
   191      */
       
   192     void DeleteMetadataL();
       
   193 
       
   194     /**
       
   195      * From MCmFmManager
       
   196      * See base class definition
       
   197      */   
       
   198     void Close();
       
   199 
       
   200 // From base class MCmFmFillRuleObserver
       
   201 
       
   202     /**
       
   203      * From MCmFmFillRuleObserver
       
   204      * See base class definition
       
   205      */   
       
   206     virtual void FillRuleProcessingStatus( TCmFmFillRuleProcessing aStatus );
       
   207 
       
   208 // From base class MCmFmTransferObserver
       
   209 
       
   210     /**
       
   211      * From MCmFmTransferObserver
       
   212      * See base class definition
       
   213      */   
       
   214     virtual void TransferStatus( TCmFmTransferStatus aStatus,
       
   215                     TInt aSessionId,
       
   216                     TInt aInternalItemId,
       
   217                     TInt aError,
       
   218                     TInt64 aFSize );
       
   219 
       
   220 // From base class MCmFmUPnPActionObserver     
       
   221 
       
   222     /**
       
   223      * From MCmFmUPnPActionObserver
       
   224      * See base class definition
       
   225      */   
       
   226     virtual void URICheckResult( TCmFmUriCheckResult aStatus,
       
   227         const CUpnpItem* aItem = NULL, const CUpnpElement* aRes = NULL );
       
   228 
       
   229 // From base class MCmFmItemHandlerObserver   
       
   230 
       
   231     /**
       
   232      * From MCmFmItemHandlerObserver
       
   233      * See base class definition
       
   234      */  
       
   235     virtual void DuplicateL( const TBool aDuplicate );                
       
   236 
       
   237 // From base class MCmMmObserver 
       
   238 
       
   239     /**
       
   240      * From MCmMmObserver
       
   241      * See base class definition
       
   242      */  
       
   243     virtual void DeleteCompleteL( TInt aErr );
       
   244 
       
   245     /**
       
   246      * From MCmMmObserver
       
   247      * See base class definition
       
   248      */  
       
   249     virtual void ShrinkCompleteL( TInt aErr );            
       
   250 
       
   251 // From base class CActive 
       
   252 
       
   253     /**
       
   254      * From CActive
       
   255      * See base class definition
       
   256      */
       
   257     void RunL();
       
   258 
       
   259     /**
       
   260      * From CActive
       
   261      * See base class definition
       
   262      */
       
   263     void DoCancel();
       
   264 
       
   265     /**
       
   266      * From CActive
       
   267      * See base class definition
       
   268      */   
       
   269     TInt RunError( TInt aError );    
       
   270 
       
   271 private:
       
   272 
       
   273     /**
       
   274      * Sets mmc quota to fill list manager
       
   275      *
       
   276      * @since S60 5.1
       
   277      * @param None
       
   278      * @return  None
       
   279      */    
       
   280     void SetMmcQuotaL();
       
   281 
       
   282     /**
       
   283      * Handles mmc id ok state
       
   284      *
       
   285      * @since S60 5.1
       
   286      * @param None
       
   287      * @return None
       
   288      */
       
   289     void HandleIfMmcOkL();
       
   290 
       
   291     /**
       
   292      * Handles if files need to be deleted
       
   293      *
       
   294      * @since S60 5.1
       
   295      * @param None
       
   296      * @return None
       
   297      */    
       
   298     void HandleIfDeleteFilesL();
       
   299 
       
   300     /**
       
   301      * Completes request
       
   302      *
       
   303      * @since S60 5.1
       
   304      * @param aStatus, completing status
       
   305      * @return None
       
   306      */
       
   307     void CompleteRequest( TCmFmStatus aStatus );
       
   308 
       
   309     /**
       
   310      * Completes request and incerements iIndex
       
   311      *
       
   312      * @since S60 5.1
       
   313      * @param aStatus, completing status
       
   314      * @return None
       
   315      */    
       
   316     void ProceedWithNextItem( TCmFmStatus aStatus );
       
   317 
       
   318     /**
       
   319      * Do uri check if needed
       
   320      *
       
   321      * @since S60 5.1
       
   322      * @param None
       
   323      * @return None
       
   324      */
       
   325     void DoUriCheckL();
       
   326     
       
   327     /**
       
   328      * Parses full path from the Uri and upnp class
       
   329      *
       
   330      * @since S60 5.1
       
   331      * @param None
       
   332      * @return Error code
       
   333      */
       
   334     TInt ParseFullPathL();
       
   335 
       
   336     /**
       
   337      * Parses file name from the Uri
       
   338      *
       
   339      * @since S60 5.1
       
   340      * @param None
       
   341      * @return Error code
       
   342      */    
       
   343     TInt ParseFileNameL();
       
   344 
       
   345     /**
       
   346      * Sets uri to current item
       
   347      *
       
   348      * @since S60 5.1
       
   349      * @param None
       
   350      * @return None
       
   351      */        
       
   352     void SetUriL();
       
   353     
       
   354     /**
       
   355      * Logs media server Uuids
       
   356      *
       
   357      * @since S60 5.1
       
   358      * @param None
       
   359      * @return None
       
   360      */        
       
   361     void LogServers();
       
   362 
       
   363     /**
       
   364      * Reset metadata item infos
       
   365      *
       
   366      * @since S60 5.1
       
   367      * @param None
       
   368      * @return None
       
   369      */        
       
   370     void ResetItemInfo();
       
   371 
       
   372     /**
       
   373      * Publishes progress info
       
   374      *
       
   375      * @since S60 5.1
       
   376      * @param aProgress, progress 
       
   377      * @return None
       
   378      */    
       
   379     void SendProgressInfo( TInt aProgress );
       
   380 
       
   381     /**
       
   382      * Sets status to ECmFilled for every reference file
       
   383      *
       
   384      * @since S60 5.1
       
   385      * @param aInternalItemId, item id
       
   386      * @return  None
       
   387      */    
       
   388     void SetStatusL( const TInt64 aInternalItemId );
       
   389 
       
   390     /**
       
   391      * Removes illegal chars from the file name
       
   392      *
       
   393      * @since S60 5.1
       
   394      * @param aFileName, file name
       
   395      * @return modified file name
       
   396      */      
       
   397     HBufC* RemoveIllegalFilenameCharactersL( const TDesC& aFileName );
       
   398 
       
   399     /**
       
   400      * Replaces defined chars
       
   401      *
       
   402      * @since S60 5.1
       
   403      * @param aString, file name string
       
   404      * @param aTrg, char to be changed
       
   405      * @param aReplacement, replacement char
       
   406      * @return None
       
   407      */    
       
   408     void ReplaceCharsL( TDes& aString, const TDesC& aTrg,
       
   409                    const TDesC& aReplacement );
       
   410 
       
   411     /**
       
   412      * Loads selected drives into iDrives array
       
   413      *
       
   414      * @since S60 5.1
       
   415      * @param None
       
   416      * @return None
       
   417      */                   
       
   418     void LoadDrivesL();                   
       
   419 
       
   420     /**
       
   421      * Updates selected drives into iDrives table
       
   422      *
       
   423      * @since S60 5.1
       
   424      * @param None
       
   425      * @return None
       
   426      */            
       
   427     void UpdateDrives();
       
   428 
       
   429     /**
       
   430      * Resolves root path of the fill drive
       
   431      *
       
   432      * @since S60 5.1
       
   433      * @param aDriveNumber, drive number
       
   434      * @return Root path
       
   435      */     
       
   436     HBufC* ResolveAndAppendRootPathL( const TInt aDriveNumber );
       
   437     
       
   438     /**
       
   439      * Updates quota of used drive
       
   440      *
       
   441      * @since S60 5.1
       
   442      * @param aDriveNumber, drive number
       
   443      * @param aQuota, new used quota
       
   444      * @return None
       
   445      */    
       
   446     void UpdateDriveQuota( const TInt aDriveNumber, 
       
   447         const TInt64 aQuota );
       
   448 
       
   449     /**
       
   450      * Initializes quotas of all selected drives
       
   451      *
       
   452      * @since S60 5.1
       
   453      * @param None
       
   454      * @return None
       
   455      */    
       
   456     void InitializeDriveQuotasL();
       
   457 
       
   458     /**
       
   459      * Initializes quotas of all selected drives
       
   460      *
       
   461      * @since S60 5.1
       
   462      * @param aDriveNumber, drive number
       
   463      * @return used fill space per drive
       
   464      */     
       
   465     TInt64 GetUsedQuota( const TInt aDriveNumber );
       
   466 
       
   467 
       
   468     /**
       
   469      * Creates RFile
       
   470      *
       
   471      * @since S60 5.1
       
   472      * @param aFilePath, file name and path
       
   473      * @return error code
       
   474      */    
       
   475     TInt CreateRFile( const TDesC& aFilePath );
       
   476     
       
   477     /**
       
   478      * Resolves private path of cm server
       
   479      *
       
   480      * @since S60 5.1
       
   481      * @param None
       
   482      * @return None
       
   483      */    
       
   484     void PrivatePathL( );
       
   485     
       
   486     /**
       
   487      * Replaces file with orginal file
       
   488      *
       
   489      * @since S60 5.1
       
   490      * @param aOriginal, orginal file name
       
   491      * @return None
       
   492      */    
       
   493     void ReplaceFileL( const TDesC& aOriginal );
       
   494 
       
   495     /**
       
   496      * Returns index to iDevices device array
       
   497      *
       
   498      * @since S60 5.1
       
   499      * @param aUuid, identifier of the server
       
   500      * @param aList, device list
       
   501      * @return index to iDevices 
       
   502      */    
       
   503     TInt CheckServerIndex( const TDesC8& aUuid,
       
   504         const CUpnpAVDeviceList& aList );
       
   505         
       
   506     /**
       
   507      * Returns ETrue if one of needed servers is available
       
   508      *
       
   509      * @since S60 5.1
       
   510      * @param None
       
   511      * @return ETrue if server available
       
   512      */     
       
   513     TBool NeededServerAvailableL( );
       
   514 
       
   515     /**
       
   516      * Reset item arrays
       
   517      *
       
   518      * @since S60 5.1
       
   519      * @param None
       
   520      * @return None
       
   521      */     
       
   522     void ResetItems();
       
   523 
       
   524     /**
       
   525      * Reset delete queue array
       
   526      *
       
   527      * @since S60 5.1
       
   528      * @param None
       
   529      * @return None
       
   530      */    
       
   531     void ResetDeleteQueue();
       
   532 
       
   533     /**
       
   534      * Adds file to delete queue
       
   535      *
       
   536      * @since S60 5.1
       
   537      * @param None
       
   538      * @return None
       
   539      */
       
   540     void AddFilesToDeleteQueueL();        
       
   541          
       
   542     /**
       
   543      * Performs operations after items have been checked
       
   544      *
       
   545      * @since S60 5.1
       
   546      * @param None
       
   547      * @return None
       
   548      */
       
   549     void StopItemCheck();
       
   550 
       
   551 private:
       
   552 
       
   553     /**
       
   554      * Performs the first phase of two phase construction.
       
   555      *
       
   556      * @since S60 5.1
       
   557      * @param aObserver, service observer
       
   558      * @param aMemManager, memory manager
       
   559      * @pram aDBManager, database manager
       
   560      */
       
   561     CCmFmMain( MCmServiceObserver* aObserver, CCmMmMain* aMemManager, 
       
   562         CCmDmMain* aDBManager );
       
   563 
       
   564     /**
       
   565      * Performs the second phase construction.
       
   566      *
       
   567      * @since S60 5.1
       
   568      * @param aSession, mde session
       
   569      * @param aDBManager, database manager
       
   570      */
       
   571     void ConstructL( CMdESession& aSession, CCmDmMain* aDBManager );
       
   572     
       
   573 
       
   574 private:
       
   575     
       
   576     /**
       
   577      * Fill manager observer
       
   578      */ 
       
   579     MCmServiceObserver* iObserver;                              // Not owned
       
   580         
       
   581     /**
       
   582      * Memory manager
       
   583      */
       
   584     CCmMmMain* iMemManager;                                     // Not owned
       
   585     
       
   586     /**
       
   587      * Database manager
       
   588      */
       
   589     CCmDmMain* iDbManager;                                      // Not owned
       
   590     
       
   591     /**
       
   592      * Upnp operation manager
       
   593      */
       
   594     CCmFmUpnpMngr* iCmFmUpnpMngr;                               // Owned
       
   595     
       
   596     /**
       
   597      * fill drive id manager
       
   598      */
       
   599     CCmFmFillDriveMngr* iCmFmFillDriveMngr;                     // Owned
       
   600     
       
   601     /**
       
   602      * Fill rule and filled data manager
       
   603      */
       
   604     CCmFmFillRuleFilledDataMngr* iCmFmFillRuleFilledDataMngr;   // Owned
       
   605 
       
   606     /**
       
   607      * Item handler, checks if media item is already in phone
       
   608      */
       
   609     CCmFmDuplicateDetector* iCmFmDuplicateDetector;             // Owned
       
   610        
       
   611     /**
       
   612      * Download proxy
       
   613      */
       
   614     CCmFmDownloadProxy* iCmFmDownloadProxy;                     // Owned
       
   615     
       
   616     /**
       
   617      * Mpx notifier
       
   618      */
       
   619     CCmFmMpxNotifier* iCmFmMpxNotifier;                         // Owned
       
   620     
       
   621     /**
       
   622      * Glx notifier
       
   623      */
       
   624     CCmFmGlxNotifier* iCmFmGlxNotifier;                         // Owned
       
   625     
       
   626     /**
       
   627      * AV Controller
       
   628      */
       
   629     MUPnPAVController* iAvController;                           // Not owned
       
   630     
       
   631     /**
       
   632      * Array of found devices
       
   633      */
       
   634     CUpnpAVDeviceList* iDevices;                                // Owned
       
   635     
       
   636     /**
       
   637      * Array of fill list items
       
   638      */
       
   639     RPointerArray<CCmFillListItem> iItems;                      // Owned
       
   640     
       
   641     /**
       
   642      * Array of to be deleted fill list items
       
   643      */
       
   644     RPointerArray<CCmFillListItem> iToBeDeleted;                // Owned
       
   645     
       
   646     /**
       
   647      * Array of to be deleted fill file names and paths
       
   648      */
       
   649     CDesCArray* iArray;                                         // Owned 
       
   650     
       
   651     /**
       
   652      * File name and path to media file
       
   653      */
       
   654     TFileName iFullPath;
       
   655     
       
   656     /**
       
   657      * Fill progress info
       
   658      */
       
   659     TCmProgressInfo iProgressInfo;
       
   660     
       
   661     /**
       
   662      * Temporary uuid
       
   663      */
       
   664     HBufC8* iUuid;                                              // Owned
       
   665     
       
   666     /**
       
   667      * Calculating fill transfer times
       
   668      */
       
   669     TTime iFileFetchStart;
       
   670     
       
   671     /**
       
   672      * Index of the current item
       
   673      */
       
   674     TInt iIndex;
       
   675     
       
   676     /**
       
   677      * Started service
       
   678      */
       
   679     TCmService iService;
       
   680     
       
   681     /**
       
   682      * Flag identifying if fill is on or not
       
   683      */
       
   684     TBool iFetchingFile;
       
   685     
       
   686     /**
       
   687      * File server session
       
   688      */
       
   689     RFs iFsSession;
       
   690     
       
   691     /**
       
   692      * Drive info table
       
   693      */
       
   694     RPointerArray<CCmDriveInfo> iDrives;
       
   695     
       
   696     /**
       
   697      * Drive id of the fill drive
       
   698      */
       
   699     TUint iDriveId;
       
   700     
       
   701     /**
       
   702      * Drive number of the fill drive
       
   703      */
       
   704     TInt iDriveNumber;
       
   705     
       
   706     /**
       
   707      * Index to drive info array
       
   708      */
       
   709     TInt iDriveIndex;
       
   710     
       
   711     /**
       
   712      * File
       
   713      */
       
   714     RFile iFile;
       
   715 
       
   716     /**
       
   717      * Index of sent items
       
   718      */
       
   719     TInt iTempIndex;
       
   720 
       
   721     };
       
   722 
       
   723 #endif //  C_CMFMMAIN_H