upnpharvester/mdhserver/inc/server/mdhmediaservercontainer.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2006-2007 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:      Metadata Harvester's media server container header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CMMDHMEDIASERVERCONTAINER_H
       
    25 #define CMMDHMEDIASERVERCONTAINER_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32std.h>
       
    29 #include <upnpavcontrolpoint.h>
       
    30 
       
    31 #include "mdhconnectionmonitorobserver.h"
       
    32 #include "mdhavcpadapter.h"
       
    33 #include "cmcommon.h"
       
    34 
       
    35 //  CONSTANTS
       
    36 
       
    37 _LIT8( KRootContainerId, "0" );
       
    38     
       
    39 _LIT8( KSearchCriteria, 
       
    40     "upnp:class derivedfrom &quot;object.item&quot; and @refID exists false");
       
    41     
       
    42 _LIT8( KSearchFilter,    "*" );
       
    43 _LIT8( KMdhSearchFilter, "dc:title,dc:date,upnp:class,"
       
    44     "upnp:album,upnp:artist,upnp:genre,res,upnp:albumArtURI,"
       
    45     "res@size,res@duration,@restricted,res@resolution,"
       
    46     "res@bitrate" );
       
    47     
       
    48 _LIT8( KSortCriteria,    "" );
       
    49 
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 class CMdHConnectionMonitor;
       
    53 class CCmMdhMetadataCollector; 
       
    54 class CCmMdhServer;
       
    55 class CCmDmMain;
       
    56 class CCmSettingsEngine;
       
    57 class CCmMediaServerFull;
       
    58 class CCmSearchResponseHash;
       
    59 class MCmSettings;
       
    60 
       
    61 // DATA TYPES
       
    62 
       
    63 enum TCmMdhMediaserverState
       
    64     {
       
    65     ECmMdhMediaserverSynchronized = 1,
       
    66     ECmMdhMediaserverNotSynchronized,
       
    67     ECmMdhMediaserverNoSearchCaps
       
    68     };
       
    69 
       
    70 // CLASS DECLARATION
       
    71 /**
       
    72 *  CCmMdhMediaserverInfo
       
    73 *  Encapsulates server information
       
    74 *
       
    75 *  @since S60 3.1
       
    76 */
       
    77 
       
    78 class CCmMdhMediaserverInfo : public CBase
       
    79     {
       
    80     public:
       
    81     
       
    82         /**
       
    83          * Creates new CCmMdhMediaserverInfo class
       
    84          * @return  pointer to CCmSmItemInfo class
       
    85          */    
       
    86         static CCmMdhMediaserverInfo* NewL();
       
    87         
       
    88         /**
       
    89          * Creates new CCmMdhMediaserverInfo class
       
    90          * @return  pointer to CCmSmItemInfo class
       
    91          */           
       
    92         static CCmMdhMediaserverInfo* NewLC();
       
    93         
       
    94         /**
       
    95          * Destructor
       
    96          */           
       
    97         ~CCmMdhMediaserverInfo();
       
    98         
       
    99     private:
       
   100     
       
   101         /**
       
   102          * Default constructor
       
   103          */              
       
   104         CCmMdhMediaserverInfo();
       
   105         
       
   106         /**
       
   107          * ConstructL
       
   108          */         
       
   109         void ConstructL();
       
   110     
       
   111     public:
       
   112         
       
   113         /** Media server identifier */
       
   114         HBufC8* iUuid;
       
   115         
       
   116         /** State of media server */
       
   117         TCmMdhMediaserverState iMediaserverState;
       
   118         
       
   119         /** media server's Systemupdate id */
       
   120         TInt iSystemUpdateId;    
       
   121     }; 
       
   122    
       
   123    
       
   124 // CLASS DECLARATION
       
   125 
       
   126 /**
       
   127 *  CCmMdhMediaserverContainer
       
   128 *  This is a class for metadata harvester server's
       
   129 *  media server container component
       
   130 *
       
   131 *  @since S60 3.1
       
   132 */
       
   133 class CCmMdhMediaserverContainer : public CCmMdhAvControlPointAdapter,
       
   134                                    public MMdHConnectionMonitorObserver
       
   135     {
       
   136     public:  // Constructors and destructor
       
   137         
       
   138         /**
       
   139         * Two-phased constructor.
       
   140         */
       
   141         static CCmMdhMediaserverContainer* NewL( CCmMdhServer& aMdhServer );
       
   142         
       
   143         /**
       
   144         * Destructor.
       
   145         */
       
   146         virtual ~CCmMdhMediaserverContainer();
       
   147         
       
   148     public: // Functions from base classes
       
   149 
       
   150         /**
       
   151         * Handles UPnP device discoveries.
       
   152         * @param aDevice Device that is discovered.
       
   153         */
       
   154         void DeviceDiscoveredL( CUpnpDevice* aDevice );
       
   155 
       
   156         /**
       
   157         * Handles UPnP device disappears.
       
   158         * @param aDevice Device that disappeared.
       
   159         */
       
   160         void DeviceDisappearedL( CUpnpDevice* aDevice );   
       
   161         
       
   162         /**
       
   163         * Observer callback for Content Directory Search function.
       
   164         * @since Series 60 2.0
       
   165         * @param aUuid Source device UUID. 
       
   166         * @param aSessionId 
       
   167         * @param aErr UPnP error code.
       
   168         * @param aContainerId
       
   169         * @param aSearchCriteria
       
   170         * @param aFilter
       
   171         * @param aIndex
       
   172         * @param arequest
       
   173         * @param aSortCriteria
       
   174         * @param aResult
       
   175         * @param aReturned
       
   176         * @param aMatches
       
   177         * @param aUpdateID
       
   178         */
       
   179         void CdsSearchResponse(
       
   180             const TDesC8& aUuid,
       
   181             TInt aSessionId,
       
   182             TInt aErr,
       
   183             const TDesC8& aContainerId,
       
   184             const TDesC8& aSearchCriteria,
       
   185             const TDesC8& aFilter,
       
   186             TInt aIndex,
       
   187             TInt aRequest,
       
   188             const TDesC8& aSortCriteria,
       
   189             const TDesC8& aResult,
       
   190             TInt aReturned,
       
   191             TInt aMatches,
       
   192             const TDesC8& aUpdateID );     
       
   193         
       
   194         /**
       
   195         * Observer callback for Content Directory 
       
   196         * GetSearchCapabilities function.
       
   197         * @since Series 60 2.0
       
   198         * @param aUuid Source device UUID. 
       
   199         * @param aSessionId 
       
   200         * @param aErr UPnP error code.
       
   201         * @param aSearchCaps
       
   202         */
       
   203         void CdsSearchCapabilitiesResponse(
       
   204             const TDesC8& aUuid,
       
   205             TInt aSessionId,
       
   206             TInt aErr,
       
   207             const TDesC8& aSearchCaps );
       
   208             
       
   209         /**
       
   210         * Observer callback for Content Directory 
       
   211         * GetSystemUpdateID function.
       
   212         * @since Series 60 2.0
       
   213         * @param aSessionId 
       
   214         * @param aErr UPnP error code.
       
   215         * @param aSystemUpdateId
       
   216         */
       
   217         void CdsSystemUpdateIdResponse(
       
   218             const TDesC8& aUuid,
       
   219             TInt aSessionId,
       
   220             TInt aErr,
       
   221             TInt aSystemUpdateId );
       
   222         
       
   223     
       
   224     public: // From MUPnPConnectionMonitorObserver
       
   225     
       
   226          /**
       
   227          * This function will be called when WLan connection is lost
       
   228          * for UPnP 
       
   229          *
       
   230          * @since S60 3.1
       
   231          */ 
       
   232          virtual void ConnectionLost();
       
   233     
       
   234              
       
   235     public: // New functions
       
   236     
       
   237         /**
       
   238         * Searchs for media servers
       
   239         * @since Series 60 2.0
       
   240         */
       
   241         void SearchMediaserversL();
       
   242         
       
   243         /**
       
   244         * Harvests media servers
       
   245         * @since Series 60 2.0
       
   246         */
       
   247         void HarvestMediaserversL();
       
   248         
       
   249         /**
       
   250         * Static timer callback function
       
   251         * @since Series 60 2.0
       
   252         * @param aNy media server container instance
       
   253         */
       
   254         static TInt SearchTimerCompletedL( TAny* aNy );
       
   255         
       
   256         /**
       
   257         * Timer callback function
       
   258         * @since Series 60 2.0
       
   259         */
       
   260         TInt DoSearchTimerCompletedL();
       
   261         
       
   262         /**
       
   263         * Harvest completion callback function
       
   264         * @param aErr error code
       
   265         * @since Series 60 2.0
       
   266         */
       
   267         void HarvestCompleteL( TInt aErr );
       
   268         
       
   269         /**
       
   270         * Cancels harvest
       
   271         * @since Series 60 2.0
       
   272         */
       
   273         void CancelSearchL();
       
   274         
       
   275         /**
       
   276         * Cancels search
       
   277         * @since Series 60 2.0
       
   278         */
       
   279         void CancelHarvestL();
       
   280         
       
   281         /**
       
   282         * Gets media server id from database
       
   283         * @since Series 60 2.0
       
   284         * @param aSearchCaps
       
   285         * @return media server id
       
   286         */
       
   287         TInt IdForMediaServerL( TDesC8& aUuid );
       
   288         
       
   289         /**
       
   290         * Sends progress info
       
   291         * @since Series 60 2.0
       
   292         * @param aProgress progressed item count
       
   293         */
       
   294         void SendProgressInfo( TInt aProgress );
       
   295 
       
   296         /**
       
   297         * Add hash for search response
       
   298         * @since S60 3.2
       
   299         * @param aMediaServerId, media server id
       
   300         * @param aSearchIndex, search index
       
   301         * @param aItemCount, item count
       
   302         * @param aHash, hash code
       
   303         * @return error code
       
   304         */        
       
   305         TInt AddHashValueForResponseL( TInt aMediaServerId, 
       
   306                                        TInt aSearchIndex, 
       
   307                                        TInt aItemCount, 
       
   308                                        const TDesC8& aHash ); 
       
   309 
       
   310         /**
       
   311         * Retrieves hash codes for defined media server
       
   312         * @since S60 3.2
       
   313         * @param aMediaServerId, media server id
       
   314         * @param aHashValues, hash codes
       
   315         * @return None
       
   316         */                                     
       
   317         void HashValuesForMediaServerL( TInt aMediaServerId,
       
   318             RPointerArray<CCmSearchResponseHash>& aHashValues );
       
   319 
       
   320         /**
       
   321         * Deletes hash values
       
   322         * @since S60 3.2
       
   323         * @param aMediaServerId, media server id
       
   324         * @param aSearchIndex, search index
       
   325         * @return None
       
   326         */
       
   327         void DeleteOldHashValuesL( const TInt aMediaserverId,
       
   328             const TInt aSearchIndex );                        
       
   329   
       
   330     private:
       
   331 
       
   332        /**
       
   333         * Constructor.
       
   334         */
       
   335         CCmMdhMediaserverContainer(CCmMdhServer& aMdhServer);
       
   336          
       
   337        /**
       
   338         * By default Symbian 2nd phase constructor is private.
       
   339         */
       
   340         void ConstructL();
       
   341         
       
   342         /**
       
   343         * Harvest a media server
       
   344         * @since Series 60 2.0
       
   345         * @param aMediaServerIndex media server array index
       
   346         */
       
   347         void DoHarvestMediaserverL( TInt aMediaserverIndex );
       
   348         
       
   349         
       
   350         /**
       
   351         * Adds a media server to database if it doesn't exist there
       
   352         * @since Series 60 2.0
       
   353         * @param aMediaServe media server device object
       
   354         * @return whether server is active or not (new servers are not active)
       
   355         */
       
   356         TBool AddToDbIfNewL( CUpnpDevice& aMediaserver );
       
   357         
       
   358         /**
       
   359         * Decreases pending responses counter and finishes search if ready
       
   360         * @since Series 60 2.0
       
   361         */
       
   362         void DecResponsesAndFinishIfReadyL();
       
   363         
       
   364         /**
       
   365         * Leaving version of method CdsSystemUpdateIdResponse.
       
   366         * @since Series 60 3.1
       
   367         * @param aErr UPnP error code.
       
   368         * @param aSystemUpdateId
       
   369         */
       
   370         void CdsSystemUpdateIdResponseL(
       
   371             const TDesC8& aUuid,
       
   372             TInt aErr,
       
   373             TInt aSystemUpdateId );
       
   374 
       
   375         /**
       
   376         * Leaving version of GetSearchCapabilities function.
       
   377         * @since Series 60 3.1
       
   378         * @param aUuid Source device UUID. 
       
   379         * @param aErr UPnP error code.
       
   380         * @param aSearchCaps
       
   381         */
       
   382         void CdsSearchCapabilitiesResponseL(
       
   383             const TDesC8& aUuid,
       
   384             TInt aErr,
       
   385             const TDesC8& aSearchCaps );
       
   386             
       
   387         /**
       
   388         * Leaving version of CdsSearchResponseL function.
       
   389         * @since Series 60 3.1
       
   390         * @param aUuid Source device UUID. 
       
   391         * @param aSessionId 
       
   392         * @param aErr UPnP error code.
       
   393         * @param aContainerId
       
   394         * @param aSearchCriteria
       
   395         * @param aFilter
       
   396         * @param aIndex
       
   397         * @param arequest
       
   398         * @param aSortCriteria
       
   399         * @param aResult
       
   400         * @param aReturned
       
   401         * @param aMatches
       
   402         * @param aUpdateID
       
   403         */
       
   404         void CdsSearchResponseL(
       
   405             const TDesC8& aUuid,
       
   406             TInt aSessionId,
       
   407             TInt aErr,
       
   408             const TDesC8& aResult,
       
   409             TInt aReturned,
       
   410             TInt aMatches );  
       
   411             
       
   412     private:    // Data
       
   413     
       
   414         // metadata collector container
       
   415         CCmMdhMetadataCollector* iMetadataCollector;    // owned
       
   416         
       
   417         // av control point
       
   418         CUpnpAVControlPoint* iAvControlPoint;           // owned
       
   419         
       
   420         // databse manager
       
   421         CCmDmMain* iDbManager;                          // owned
       
   422         
       
   423         // reference to host server
       
   424         CCmMdhServer& iMdhServer;
       
   425         
       
   426         // Settings engine
       
   427         MCmSettings*        iSettings;                  // owned
       
   428         
       
   429         // Connection monitor
       
   430         CMdHConnectionMonitor* iMdHConMon;              // owned
       
   431         
       
   432         // timer 
       
   433         CPeriodic* iTimer;                              // owned
       
   434         
       
   435         // array for media server information
       
   436         RPointerArray<CCmMdhMediaserverInfo> iMediaservers; // items owned
       
   437         
       
   438         // array of old media servers
       
   439         RPointerArray<CCmMediaServerFull> iOldMediaServers; // items owned
       
   440         
       
   441         TCmProgressInfo iProgressInfo;
       
   442         
       
   443         // index for storing which media server we are harvesting
       
   444         TInt iMediaserverIndex;
       
   445         
       
   446         TInt iResponsesPending;
       
   447         
       
   448         TInt iTotalItemCount;
       
   449  
       
   450         // The IAP that is used
       
   451         TInt iIap;
       
   452         
       
   453         TBool iHarvestErrCode;
       
   454         
       
   455         TBool iHarvestActive;
       
   456         
       
   457         TBool iAllFound;
       
   458         
       
   459         //index of havest item which has been sent to property
       
   460         TInt iPropertyItemIndex;
       
   461    
       
   462     };
       
   463 
       
   464 #endif      // CMMDHMEDIASERVERCONTAINER_H   
       
   465             
       
   466 // End of File