homesync/contentmanager/cmserver/cmfillmanager/inc/cmfmfillrulefilleddatamngr.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     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:  Fill rule and filled data managing
       
    15 *  Version     : %version: tr1ido#8 % << Don't touch!
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CMFMFILLLIST_H
       
    22 #define __CMFMFILLLIST_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 #include "cmcommontypes.h"
       
    27 #include "cmcommon.h"
       
    28 #include "cmfmcommon.h"
       
    29 
       
    30 // Forward declarations
       
    31 class MCmSqlMain;
       
    32 class CCmDmMain;
       
    33 class CCmFillRule;
       
    34 class CCmFillListItem;
       
    35 class CCmFillRuleContainer;
       
    36 class CCmSqlPropertyItem;
       
    37 class CCmSqlPropertyContainer;
       
    38 class CCmFmAo;
       
    39 class MCmFmFillRuleObserver;
       
    40 class CCmSqlPropertyCollector;
       
    41              
       
    42  /**
       
    43   *  Class processes selected fill rules. Uses Database Manager and 
       
    44   *  Sqlite wrapper API to retrieve wanted metadata. Fill service is 
       
    45   *  started using processed metadata items. 
       
    46   *
       
    47   *  @lib cmfillmanager.lib
       
    48   *
       
    49   *  @since S60 5.1
       
    50   */
       
    51 NONSHARABLE_CLASS( CCmFmFillRuleFilledDataMngr ): public CActive
       
    52     {
       
    53 
       
    54 private: // enumerations
       
    55 
       
    56     // Metadata processing states
       
    57     enum TCmFmMetadaProcessingState
       
    58         {
       
    59         ECmFmIdle            = 0,
       
    60         ECmFmLoadingMetadata,
       
    61         ECmFmLoadingPropertys,
       
    62         ECmFmDeletingMetadata,
       
    63         ECmFmLoadingProfileIds
       
    64         };         
       
    65             
       
    66 public:
       
    67        
       
    68     /**
       
    69      * Two-phased constructor.
       
    70      *
       
    71      * @since S60 5.1
       
    72      * @param aObserver, observer for metadata processing
       
    73      * @param aDBMngr, database manager
       
    74      * @param aItems, items pointers array
       
    75      * @return  pointer to CCmFmFillRuleFilledDataMngr class
       
    76      */
       
    77     static CCmFmFillRuleFilledDataMngr* NewL(
       
    78         MCmFmFillRuleObserver* aObserver, CCmDmMain* aDBMngr,
       
    79         RPointerArray<CCmFillListItem>& aItems );
       
    80     
       
    81     /**
       
    82      * Two-phased constructor.
       
    83      *
       
    84      * @since S60 5.1
       
    85      * @param aObserver, observer for metadata processing
       
    86      * @param aDBMngr, database manager
       
    87      * @param aItems, items pointers array
       
    88      * @return  pointer to CCmFmFillRuleFilledDataMngr class
       
    89      */
       
    90     static CCmFmFillRuleFilledDataMngr* NewLC(
       
    91         MCmFmFillRuleObserver* aObserver, CCmDmMain* aDBMngr,
       
    92         RPointerArray<CCmFillListItem>& aItems );
       
    93 
       
    94     /**
       
    95      * Destructor.
       
    96      */
       
    97     virtual ~CCmFmFillRuleFilledDataMngr();
       
    98 
       
    99 public: 
       
   100 
       
   101     /**
       
   102      * Notified when asyncronous operation is completed
       
   103      *
       
   104      * @since S60 5.1
       
   105      * @param aStatus, completion status
       
   106      * @return None
       
   107      */ 
       
   108     void OperationCompletedL( TInt aStatus );
       
   109 
       
   110    /**
       
   111      * Loads profile ids from database
       
   112      *
       
   113      * @since S60 5.1
       
   114      * @param None
       
   115      * @return None
       
   116      */ 
       
   117     void LoadProfileIdsL();
       
   118         
       
   119     /**
       
   120      * Starting fill rule pre-processing
       
   121      *
       
   122      * @since S60 5.1
       
   123      * @param None
       
   124      * @return None
       
   125      */    
       
   126     void PreprocessListsL();
       
   127     
       
   128     /**
       
   129      * Starting fill rule processing
       
   130      *
       
   131      * @since S60 5.1
       
   132      * @param aFillListName, name of the list
       
   133      * @return None
       
   134      */    
       
   135     void PreProcessListL( const TDesC8& aFillListName );
       
   136     
       
   137     /**
       
   138      * Provides metadata column item list
       
   139      *
       
   140      * @since S60 5.1
       
   141      * @param aType, metadata field identifier
       
   142      * @param aMedia, media type identifier
       
   143      * @param aPropertys, property container reference
       
   144      * @return  None
       
   145      */
       
   146     void GetColItemsL( TCmMetadataField aType, 
       
   147         TCmMediaType aMedia, CCmSqlPropertyContainer& aPropertys );   
       
   148 
       
   149     /**
       
   150      * Provides metadata items list
       
   151      *
       
   152      * @since S60 5.1
       
   153      * @param aPropertys, property collector reference
       
   154      * @return  None
       
   155      */    
       
   156     void GetMetadataItemsL( CCmSqlPropertyCollector& aPropertys );
       
   157     
       
   158     /**
       
   159      * Update fill list item priorities and reference values
       
   160      *
       
   161      * @since S60 5.1
       
   162      * @param None
       
   163      * @return  None
       
   164      */
       
   165     void UpdatePriorities();
       
   166 
       
   167     /**
       
   168      * Do update fill list item reference ids
       
   169      *
       
   170      * @since S60 5.1
       
   171      * @param None
       
   172      * @return  None
       
   173      */
       
   174     void DoUpdateReferenceIdsL();
       
   175 
       
   176     /**
       
   177      * Delete metadata from unselected servers
       
   178      *
       
   179      * @since S60 5.1
       
   180      * @param None
       
   181      * @return  None
       
   182      */ 
       
   183     void DeleteMetadataL();
       
   184                 
       
   185     /**
       
   186      * Sets memory card quota to wrapper
       
   187      *
       
   188      * @since S60 5.1
       
   189      * @param aQuota, fill quota
       
   190      * @return  None
       
   191      */    
       
   192     void SetMemoryCardQuota( TInt64 aQuota );
       
   193     
       
   194     /**
       
   195      * Canceling operations
       
   196      *
       
   197      * @since S60 5.1
       
   198      * @param None
       
   199      * @return None
       
   200      */    
       
   201     void CancelOperation();
       
   202     
       
   203     /**
       
   204      * Updating transfer history
       
   205      *
       
   206      * @since S60 5.1
       
   207      * @param aInterval, used time
       
   208      * @param aDataAmount, amount of transferred data
       
   209      * @param aServerId, server from where data transferred
       
   210      * @return  None
       
   211      */
       
   212     void UpdateTransferHistoryData( TInt64 aInterval,
       
   213                                     TInt64 aDataAmount,
       
   214                                     TUint8 aServerId );
       
   215 
       
   216     /**
       
   217      * Loads wanted items from the db
       
   218      *
       
   219      * @since S60 5.1
       
   220      * @param None
       
   221      * @return  None
       
   222      */                            
       
   223     void GetFillItemsL();
       
   224 
       
   225     /**
       
   226      * Loads to be deleted items from the db
       
   227      *
       
   228      * @since S60 5.1
       
   229      * @param aArray, array of to be deleted items
       
   230      * @return  None
       
   231      */        
       
   232     void GetToBeDeletedL( RPointerArray<CCmFillListItem>& aArray );
       
   233 
       
   234     /**
       
   235      * Updates listed items into db
       
   236      *
       
   237      * @since S60 5.1
       
   238      * @param aCancel, if this opration is called by cancel harvest
       
   239      * @return  None
       
   240      */       
       
   241     void UpdateFillItems( TBool aCancel = EFalse );
       
   242 
       
   243     /**
       
   244      * Updates listed items into db
       
   245      *
       
   246      * @since S60 5.1     
       
   247      * @param aArray, array of to be deleted items
       
   248      * @return  None
       
   249      */        
       
   250     void UpdateToBeDeleted( RPointerArray<CCmFillListItem>& aArray );
       
   251 
       
   252     /**
       
   253      * Loads right Uuid 
       
   254      *
       
   255      * @since S60 5.1
       
   256      * @param aUuid, contains uuid on return
       
   257      * @param aId, id of the wanted uuid
       
   258      * @return error code
       
   259      */        
       
   260     TInt GetUuidL( HBufC8*& aUuid, TUint8 aId );
       
   261     
       
   262    /**
       
   263      * Resets allocated data
       
   264      *
       
   265      * @since S60 5.1
       
   266      * @param None
       
   267      * @return None
       
   268      */     
       
   269     void ResetData();
       
   270         
       
   271    /**
       
   272      * Calculating transfer history time
       
   273      *
       
   274      * @since S60 5.1
       
   275      * @param None
       
   276      * @return None
       
   277      */        
       
   278     void CalculateAvgTransferTimeL();
       
   279     
       
   280    /**
       
   281      * Publishes transfer history time estimate
       
   282      *
       
   283      * @since S60 5.1
       
   284      * @param None
       
   285      * @return None
       
   286      */    
       
   287     void SendAvgTransferTime();
       
   288     
       
   289     /**
       
   290      * Returns media servers db id
       
   291      *
       
   292      * @since S60 5.1
       
   293      * @param aUuid, media server's uuids
       
   294      * @return database id
       
   295      */     
       
   296     TInt64 GetMediaServerIdL( const TDesC8& aUuid );            
       
   297                                     
       
   298 private:
       
   299 
       
   300     /**
       
   301      * Do update fill list item priorities
       
   302      *
       
   303      * @since S60 5.1
       
   304      * @param None
       
   305      * @return None
       
   306      */    
       
   307     void DoUpdatePrioritiesL();
       
   308         
       
   309     /**
       
   310      * Loading all selected fill rules
       
   311      *
       
   312      * @since S60 5.1
       
   313      * @param None
       
   314      * @return None
       
   315      */        
       
   316     void LoadSelectedFillRulesL();
       
   317 
       
   318     /**
       
   319      * Loading all fill rules
       
   320      *
       
   321      * @since S60 5.1
       
   322      * @param None
       
   323      * @return Fill rule container
       
   324      */ 
       
   325     CCmFillRuleContainer* LoadAllFillRulesL();
       
   326     
       
   327     /**
       
   328      * Loads defined fill list
       
   329      *
       
   330      * @since S60 5.1
       
   331      * @param aFillListName, name of the list
       
   332      * @return None
       
   333      */        
       
   334     void LoadRuleL( const TDesC8& aFillListName );
       
   335     
       
   336     /**
       
   337      * Updates fill list item priorities up to date
       
   338      *
       
   339      * @since S60 5.1
       
   340      * @param aContainer, container containing all rules
       
   341      * @return None
       
   342      */     
       
   343     TInt UpdateListItemPriorities( CCmFillRuleContainer* aContainer );
       
   344             
       
   345     /**
       
   346      * Initializing metadata find
       
   347      *
       
   348      * @since S60 5.1
       
   349      * @param aFillRule, fill list
       
   350      * @return None
       
   351      */                        
       
   352     void LoadMetadataL( CCmFillRule* aFillRule );
       
   353     
       
   354     /**
       
   355      * Processing possible fill file list duplicates 
       
   356      * and adds reference values if needed
       
   357      *
       
   358      * @since S60 5.1
       
   359      * @param None
       
   360      * @return None
       
   361      */        
       
   362     void ProcessReferenceValuesL();
       
   363 
       
   364     /**
       
   365      * Processes possible fill file list duplicates 
       
   366      * and adds reference values if needed
       
   367      *
       
   368      * @since S60 5.1
       
   369      * @param None
       
   370      * @return None
       
   371      */        
       
   372     void DoProcessReferenceValuesL();
       
   373     
       
   374     /**
       
   375      * Processing possible fill file list duplicates,
       
   376      * removes duplicates appeared in new sql query
       
   377      * If same item is twice in item list, 
       
   378      * new item is removed
       
   379      *
       
   380      * @since S60 5.1
       
   381      * @param None
       
   382      * @return None
       
   383      */    
       
   384     void ProcessDuplicates();
       
   385     
       
   386     /**
       
   387      * Selects fill list files which are with defined rule id
       
   388      *
       
   389      * @since S60 5.1
       
   390      * @param aList, list to be filled
       
   391      * @param aId, fill list id
       
   392      * @return None
       
   393      */        
       
   394     void SelectFillListFiles( RArray<TInt>& aList, TUint8 aId );
       
   395     
       
   396     /**
       
   397      * Updates status values of the fill list files
       
   398      *
       
   399      * @since S60 5.1
       
   400      * @param None
       
   401      * @return None
       
   402      */    
       
   403     void ProcessFileStatusValuesL();
       
   404     
       
   405      /**
       
   406      * Updatas the fill file's ids.
       
   407      *
       
   408      * @since S60 5.1
       
   409      * @param aDelIds,array to store files's id 
       
   410      * @param aIndex, Index of fill items
       
   411      * @param aRealCount, count of fill items
       
   412      * @param aRealSize, size of fill items
       
   413      * @return None
       
   414      */ 
       
   415      void ProcessFileSizeAndCount( RArray<TInt>& aDelIds, TInt aIndex, 
       
   416                             TInt64& aRealCount, TInt64& aRealSize );
       
   417 
       
   418     /**
       
   419      * Loads all fill file items
       
   420      *
       
   421      * @since S60 5.1
       
   422      * @param None
       
   423      * @return None
       
   424      */    
       
   425     void LoadAllFillItemsL();
       
   426     
       
   427     /**
       
   428      * Delete duplicated fill items and adjust array
       
   429      *
       
   430      * @since S60 5.1
       
   431      * @param aIndex, Index array of fill items
       
   432      */     
       
   433 	void DoDeleteProcess( TInt aIndex );
       
   434 
       
   435    /**
       
   436      * Defines unsupported dlna profile ids
       
   437      *
       
   438      * @since S60 5.1
       
   439      * @param None
       
   440      * @return None
       
   441      */ 
       
   442     void DefineAndSetDlnaProfileIdFiltersL();   
       
   443 
       
   444    /**
       
   445      * Completes request
       
   446      *
       
   447      * @since S60 5.1
       
   448      * @param aStatus, defined id for the completing 
       
   449      * @return None
       
   450      */     
       
   451     void CompleteRequest( TCmFmFillRuleProcessing aStatus );
       
   452  
       
   453     /**
       
   454      * Starts asyncronous operartion observer
       
   455      * i.e. creates active object
       
   456      * @since S60 5.1
       
   457      * @param None
       
   458      * @return None
       
   459      */    
       
   460     void StartObserverL();
       
   461 
       
   462     /**
       
   463      * Creates metadata cache wrapper
       
   464      * @since S60 5.1
       
   465      * @param None
       
   466      * @return None
       
   467      */    
       
   468     void CreateWrapperL();
       
   469     
       
   470     /**
       
   471      * Deletes metadata cache wrapper
       
   472      * @since S60 5.1
       
   473      * @param None
       
   474      * @return None
       
   475      */ 
       
   476     void DeleteWrapper();     
       
   477 
       
   478     /**
       
   479      * Processes fill lists
       
   480      * @since S60 5.1
       
   481      * @param None
       
   482      * @return None
       
   483      */ 
       
   484     void CheckFillListsL();
       
   485     
       
   486     /**
       
   487      * Deletes hash codes
       
   488      * @since S60 5.2
       
   489      * @param None
       
   490      * @return None
       
   491      */ 
       
   492     void DeleteHashCodesL();
       
   493     
       
   494 protected: 
       
   495 
       
   496 // Functions from base class CActive
       
   497 
       
   498     /**
       
   499      * From CActive
       
   500      * See base class definition
       
   501      */
       
   502     void RunL();
       
   503 
       
   504     /**
       
   505      * From CActive
       
   506      * See base class definition
       
   507      */
       
   508     void DoCancel();
       
   509 
       
   510     /**
       
   511      * From CActive
       
   512      * See base class definition
       
   513      */
       
   514     virtual TInt RunError(TInt aError);
       
   515         
       
   516 private:
       
   517 
       
   518     /**
       
   519      * Performs the first phase of two phase construction.
       
   520      *
       
   521      * @since S60 5.1
       
   522      * @param aObserver, Fill list observer
       
   523      * @param aDBMngr, database manager
       
   524      * @param aItems, array of list items
       
   525      */
       
   526     CCmFmFillRuleFilledDataMngr( MCmFmFillRuleObserver* aObserver, 
       
   527         CCmDmMain* aDBMngr, RPointerArray<CCmFillListItem>& aItems );
       
   528 
       
   529     /**
       
   530      * Performs the second phase construction.
       
   531      */
       
   532     void ConstructL();
       
   533     
       
   534 
       
   535 private:
       
   536 
       
   537     /**
       
   538      * Metadata cache wrapper
       
   539      */
       
   540     MCmSqlMain* iWrapper;                           // owned
       
   541     
       
   542     /**
       
   543      * Active object in use of sql wrapper
       
   544      */
       
   545     CCmFmAo* iAo;                                   // owned
       
   546     
       
   547     /**
       
   548      * Pointer to observer class
       
   549      */
       
   550     MCmFmFillRuleObserver* iObserver;               // not owned
       
   551     
       
   552     /**
       
   553      * Pointer to database manager
       
   554      */
       
   555     CCmDmMain* iDBManager;                          // not owned
       
   556     
       
   557     /**
       
   558      * All fill list items
       
   559      */
       
   560     RPointerArray<CCmFillListItem>& iItems;         // not owned
       
   561 
       
   562     /**
       
   563      * fill list items for updating to DB
       
   564      */
       
   565     RPointerArray<CCmFillListItem> iUpdateItems;    //owned
       
   566     
       
   567     /**
       
   568      * Property values loaded from the cache
       
   569      */
       
   570     RPointerArray<CCmSqlPropertyItem> iPropertys;   // owned
       
   571     
       
   572     /**
       
   573      * Property container referencing got from client
       
   574      */
       
   575     CCmSqlPropertyContainer* iPropertyContainer;    // not owned
       
   576 
       
   577     /**
       
   578      * Property container referencing got from client
       
   579      */
       
   580     CCmSqlPropertyCollector* iPropertyCollector;    // not owned           
       
   581         
       
   582     /**
       
   583      * Rule array
       
   584      */
       
   585     RPointerArray<CCmFillRule> iRuleArray;
       
   586     
       
   587     /**
       
   588      * Item ids on the list
       
   589      */    
       
   590     RArray<TInt> iFileIds;
       
   591     
       
   592     /**
       
   593      * State of the metadata processing
       
   594      */ 
       
   595     TCmFmMetadaProcessingState iProcessingState;
       
   596     
       
   597     /**
       
   598      * Count of new metadata items
       
   599      */ 
       
   600     TInt iNewItemCount;
       
   601     
       
   602     /**
       
   603      * Count of all metadata items
       
   604      */
       
   605     TInt iAllItemCount;
       
   606     
       
   607     /**
       
   608      * Start time of list processing
       
   609      */
       
   610     TTime iQueryStart;
       
   611     /**
       
   612      * End time of list processing
       
   613      */    
       
   614     TTime iQueryFinished;
       
   615     
       
   616     /**
       
   617      * Total transfer time estimate
       
   618      */
       
   619     TCmProgressInfo iTransferInfo;
       
   620     
       
   621     /**
       
   622      * Container for fill lists
       
   623      */
       
   624     CCmFillRuleContainer* iContainer;               // owned
       
   625 
       
   626     /**
       
   627      * Server list whose metadata will be deleted
       
   628      */    
       
   629     RArray<TInt> iMetadataServersToBeDeleted;
       
   630     
       
   631     /**
       
   632      * Profile filters
       
   633      */    
       
   634     RArray<TInt64> iFilteredProfiles;
       
   635     
       
   636     /**
       
   637      * File Server session
       
   638      */
       
   639     RFs iFs;
       
   640     
       
   641     /**
       
   642      * Old item ids on the list
       
   643      */    
       
   644     RArray<TInt> iOldIds;
       
   645    
       
   646     };
       
   647 
       
   648 #endif //  __CMFMFILLLIST_H