browserutilities/downloadmgr/DownloadMgrServEng/Inc/HttpDownloadManagerServerEngine.h
changeset 0 dd21522fd290
child 24 9993978961bf
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 the License "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:  
       
    15 *       This class implements download manager.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef HTTPDOWNLOADMANAGER_H
       
    22 #define HTTPDOWNLOADMANAGER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include "HttpDownload.h"
       
    26 
       
    27 #include <HttpDownloadMgrCommon.h>
       
    28 #include <e32std.h>
       
    29 #include <f32file.h>
       
    30 
       
    31 #include <e32property.h>
       
    32 #include <UikonInternalPSKeys.h>
       
    33 
       
    34 // CONSTANTS
       
    35 const TInt KMaxDriveListStrLen = KMaxDrives << 1;
       
    36 
       
    37 // MACROS
       
    38 //#define ?macro ?macro_def
       
    39 
       
    40 // DATA TYPES
       
    41 //enum ?declaration
       
    42 //typedef ?declaration
       
    43 //extern ?data_type;
       
    44 
       
    45 // FUNCTION PROTOTYPES
       
    46 #if defined(_DEBUG)
       
    47 void DMPanic( TInt aPanicCode );
       
    48 #else
       
    49 #define DMPanic( a )
       
    50 #endif
       
    51 
       
    52 // FORWARD DECLARATIONS
       
    53 class CHttpDownload;
       
    54 class CHttpClientApp;
       
    55 class CHttpClientAppInstance;
       
    56 class RFs;
       
    57 class CDocumentHandler;
       
    58 
       
    59 // CLASS DECLARATION
       
    60 
       
    61 NONSHARABLE_CLASS( MMMCObserver )
       
    62     {
       
    63     public:
       
    64     
       
    65         virtual void MMCModeChanged( TBool aAllowed ) = 0;
       
    66     };
       
    67     
       
    68 NONSHARABLE_CLASS( CMMCNotifier ) : public CActive
       
    69 	{
       
    70 	public:
       
    71 	
       
    72 		/**
       
    73 		* constructor
       
    74 		*/
       
    75 		CMMCNotifier( RProperty* aProperty );
       
    76 		
       
    77 		/**
       
    78 		* Destructor
       
    79 		*/
       
    80 		virtual ~CMMCNotifier();
       
    81 		
       
    82 		void StartObserving( MMMCObserver* aObserver );
       
    83 		
       
    84 	public: // from CActive
       
    85 	
       
    86 	    virtual void RunL();
       
    87 	    virtual void DoCancel();
       
    88 	
       
    89 	private:
       
    90 	
       
    91 		RProperty* iProperty;
       
    92 		MMMCObserver* iObserver;
       
    93 	};
       
    94 
       
    95 typedef struct
       
    96     {
       
    97     TInt    iDriveLetter;
       
    98     TInt    iDriveId;
       
    99     TBool   iRemovable;
       
   100     }TDriveStr;
       
   101     
       
   102 /**
       
   103 *  This class maintains the list of all existing downloads and applications
       
   104 *  they initiated from.
       
   105 *
       
   106 *  @lib DManager.lib
       
   107 *  @since S60 2.8
       
   108 */
       
   109 NONSHARABLE_CLASS( CHttpDownloadManagerServerEngine ) : public CBase
       
   110                                                        ,public MMMCObserver
       
   111     {
       
   112     public:  // Constructors and destructor
       
   113         
       
   114         /**
       
   115         * Two-phased constructor.
       
   116         */
       
   117         IMPORT_C static CHttpDownloadManagerServerEngine* NewL();
       
   118         
       
   119         /**
       
   120         * Destructor.
       
   121         */
       
   122         virtual ~CHttpDownloadManagerServerEngine();
       
   123 
       
   124     public: // New functions
       
   125         
       
   126         /**
       
   127         * Closes the engine.
       
   128         * @since Series 60 v2.8
       
   129         * @param aStore if ETrue 
       
   130         * @return none.
       
   131         */
       
   132         IMPORT_C void CloseEngine( TBool aStore = ETrue );
       
   133 
       
   134         /**
       
   135         * Creates a new client application instance
       
   136         * @since Series 60 v2.8
       
   137         * @param aAppUid UId of the client application
       
   138         * @param aObserver download state observer
       
   139         * @param aGetAllPendingDownloads if ETrue this instance gets all non-attached downloads
       
   140         * @return pointer to the created instance. Ownership now passed.
       
   141         */
       
   142         IMPORT_C CHttpClientAppInstance* CreateNewClientAppInstanceL( 
       
   143                                         TUint32 aAppUid, 
       
   144                                         MDownloadStateObserver* aObserver,
       
   145                                         TBool aGetAllPendingDownloads );
       
   146 
       
   147         /**
       
   148         * Closes the given client application instance.
       
   149         * @since Series 60 v2.8
       
   150         * @param aAppInst client instance to be closed
       
   151         * @return none.
       
   152         */
       
   153         IMPORT_C void CloseClientInstance( CHttpClientAppInstance* aAppInst );
       
   154 
       
   155         /**
       
   156         * Returns the number of active download in the engine. 
       
   157         * @since Series 60 v2.8
       
   158         * @param ?arg1 ?description
       
   159         * @return ?description
       
   160         */
       
   161         EXPORT_C TInt ActiveDownloads() const;
       
   162 
       
   163         /**
       
   164         * Calculates the total size of all on-going downloads in the 
       
   165         * Download manager. Downloads which have been completed are not
       
   166         * taken to be part of this size.
       
   167         * @since Series 60 v3.2
       
   168         * @return TInt : Total size of all downloads currently under progress. 
       
   169         */
       
   170 		TInt AllDownloadsSizeL( const CHttpDownload *aDownload ) const;
       
   171 
       
   172 
       
   173         /**
       
   174         * Calculates the total size of all on-going downloads in the current 
       
   175         * drive (where current download is in progress)
       
   176         * @since Series 60 v3.2
       
   177         * @return TInt : Total size of all downloads currently under progress in the drive. 
       
   178         */
       
   179 		TInt AllDownloadsSizeInDriveL( const CHttpDownload *aDownload, TInt aDriveId ) const;
       
   180 
       
   181         /**
       
   182         * Search for download identified with id in every 
       
   183         * client application and check if download with the
       
   184         * aDownloadId has been attached already. It is not allowed to
       
   185 		* attach the same download to more than one application.
       
   186         * @since Series 60 v3.2
       
   187         * @param aDownload id of the download to be search for
       
   188         * @return Bool ETrue - if the download has been attached already. 
       
   189         */
       
   190 		TBool IsAttachedAlready(TInt32 aDownloadId);
       
   191 
       
   192         /**
       
   193         * Search for download identified with id in every 
       
   194         * client application.
       
   195         *
       
   196         * @since Series 60 v3.2
       
   197         * @param aDownload id of the download to be found
       
   198         * @return download identified with id
       
   199         */
       
   200         CHttpDownload* FindDownload( TInt32 aDownloadId );
       
   201 
       
   202         /**
       
   203         * Returns the client specific folder.
       
   204         * @since Series 60 v2.8
       
   205         * @param aClientApp client application
       
   206         * @param aFolder private folder of the client application
       
   207         * @return none.
       
   208         */
       
   209         void ClientAppFolder( const CHttpClientApp* aClientApp, 
       
   210                               TDes& aFolder );
       
   211 
       
   212         /**
       
   213         * Returns the client specific folder w/o the drive letter.
       
   214         * @since Series 60 v2.8
       
   215         * @param aClientApp client application
       
   216         * @param aFolder private folder of the client application
       
   217         * @return none.
       
   218         */
       
   219         void ClientAppFolderWithoutDriveLetter( const CHttpClientApp* aClientApp, 
       
   220                                                 TDes& aFolder );
       
   221 
       
   222         /**
       
   223         * Returns the folder name of the download info files.
       
   224         * @since Series 60 v2.8
       
   225         * @param aDownload download
       
   226         * @param aFolder private folder of the download
       
   227         * @return none.
       
   228         */
       
   229         void DownloadInfoFolder( const CHttpClientApp* aClientApp, 
       
   230                                  TDes& aFolder ) const;
       
   231 
       
   232         /**
       
   233         * Returns the folder name of the download info files.
       
   234         * @since Series 60 v2.8
       
   235         * @param aDownload download
       
   236         * @param aFolder private folder of the download
       
   237         * @return none.
       
   238         */
       
   239         void CODDownloadInfoFolder( const CHttpClientApp* aClientApp, 
       
   240                                  TDes& aFolder ) const;
       
   241                                  
       
   242         /**
       
   243         * Returns the folder name of the download content files.
       
   244         * @since Series 60 v2.8
       
   245         * @param aDownload download
       
   246         * @param aFolder private folder of the download
       
   247         * @return none.
       
   248         */
       
   249         void DownloadContentFolder( const CHttpClientApp* aClientApp, 
       
   250                                     TDes& aFolder ) const;
       
   251 
       
   252         /**
       
   253         * Return the clients app's COD folder
       
   254         */
       
   255         void CodFolder( const CHttpClientApp* aClientApp, 
       
   256                         TDes& aFolder ) const;
       
   257 
       
   258 #ifdef DEAD_CODE        
       
   259         /**
       
   260         * Returns every download maintained in the engine.
       
   261         * @since Series 60 v2.8
       
   262         * @return array of every download in the engine.
       
   263         */
       
   264         CArrayPtrFlat<CHttpDownload>* AllDownloadsL() const;
       
   265 #endif
       
   266 
       
   267         /**
       
   268         * Returns the engine's own RFs
       
   269         * @since Series 60 v2.8
       
   270         * @return reference to the engine's own RFs
       
   271         */
       
   272         RFs& Fs();
       
   273 
       
   274         /**
       
   275         * Returns a connected socket server.
       
   276         * @since Series 60 v2.8
       
   277         * @return reference to the socket server
       
   278         */
       
   279         RSocketServ& SocketServ();
       
   280 
       
   281         /**
       
   282         * Returns a global unique download id
       
   283         * @since Series 60 v2.8
       
   284         * @return global unique download id
       
   285         */
       
   286         TInt NextDownloadId();
       
   287         
       
   288         /**
       
   289         * Returns the server's document handler
       
   290         * @return pointer to a document instance
       
   291         */
       
   292         CDocumentHandler* DocHandler() const;
       
   293 
       
   294         /**
       
   295         * Returns a Bool
       
   296         * @since Series 60 v3.2
       
   297         * @return Bool
       
   298         */
       
   299         TBool IsEngineClosing()const { return iEngineClosing; };
       
   300 
       
   301 #ifdef RD_MULTIPLE_DRIVE
       
   302         /**
       
   303         * Query the dynamic drive list.
       
   304         */
       
   305         HBufC8* QueryDynDriveListLC();
       
   306 #endif
       
   307 
       
   308         /**
       
   309         *
       
   310         */
       
   311         TBool ProgressiveDownloadFeature(){ return iFeatProgressiveDownload; }
       
   312 
       
   313     public: // Functions from base classes
       
   314 
       
   315         void MMCModeChanged( TBool aAllowed );
       
   316 
       
   317     protected:  // New functions
       
   318         
       
   319         /**
       
   320         * Creates a new client application.
       
   321         * @since Series 60 v2.8
       
   322         * @param aAppUid UId of the new client application
       
   323         * @return created client application. Ownership not passed.
       
   324         */
       
   325         CHttpClientApp* CreateNewClientAppL( TUint32 aAppUid );
       
   326 
       
   327         /**
       
   328         * Loads client from file. Not used. For later implemenations.
       
   329         * @since Series 60 v2.8
       
   330         * @return none. Leaves on failure.
       
   331         */
       
   332         void LoadClientsL();
       
   333 
       
   334         /**
       
   335         * Converts folder name to client id.
       
   336         * @since Series 60 v2.8
       
   337         * @param aClientDir folder of the client application
       
   338         * @return id of the client application
       
   339         */
       
   340         TUint32 CheckClientDirName( TDesC& aClientDir );
       
   341 
       
   342         /**
       
   343         * Set iMMCUniqueID with unique id of MMC card inserted into the phone.
       
   344         * KErrNotFound is not inserted.
       
   345         */
       
   346         void QueryMMCUniqueId();
       
   347 
       
   348         /**
       
   349         * Query the drive list from the CentRep.
       
   350         */
       
   351         void QueryDriveListL();
       
   352 
       
   353         /**
       
   354         * Returns iMMCUniqueID
       
   355         * @return iMMCUniqueID
       
   356         */
       
   357         TUint MMCUniqueId() const;
       
   358         
       
   359         /**
       
   360         *
       
   361         */
       
   362         TInt CheckFreeDiskSpaceL( HBufC* aFilename, TInt aLength );
       
   363 
       
   364     protected:  // Functions from base classes
       
   365         
       
   366     private:
       
   367 
       
   368         /**
       
   369         * C++ default constructor.
       
   370         */
       
   371         CHttpDownloadManagerServerEngine();
       
   372 
       
   373         /**
       
   374         * By default Symbian 2nd phase constructor is private.
       
   375         */
       
   376         void ConstructL();
       
   377 
       
   378     public:     // Data
       
   379 
       
   380         TBuf<KMaxDriveListStrLen> iDriveLettersCenRep;
       
   381         
       
   382     protected:  // Data
       
   383 
       
   384         CArrayPtrFlat<CHttpClientApp>* iClientApps;
       
   385         RFs                 iRfs;
       
   386 
       
   387 		RProperty *iProperty;
       
   388 		CMMCNotifier *iMMCNotifier;
       
   389 
       
   390         RSocketServ         iSocketServ;
       
   391         
       
   392         TInt        iNextDownloadId;
       
   393 
       
   394         // KErrNotFound is not present
       
   395         TUint iMMCUniqueID;
       
   396         
       
   397         CDocumentHandler*   iDocHandler;
       
   398 
       
   399         TBool               iEngineClosing;
       
   400         
       
   401         TBool               iFeatProgressiveDownload;
       
   402 
       
   403     private:    // Data
       
   404         // ?one_line_short_description_of_data
       
   405         //?data_declaration;
       
   406          
       
   407         // Reserved pointer for future extension
       
   408         //TAny* iReserved;
       
   409 
       
   410     public:     // Friend classes
       
   411         //?friend_class_declaration;
       
   412     protected:  // Friend classes
       
   413         // to provide access to client apps array
       
   414         //?friend_class_declaration;
       
   415     private:    // Friend classes
       
   416         //?friend_class_declaration;
       
   417 
       
   418     };
       
   419 
       
   420 #endif      // HTTPDOWNLOADMANAGER_H
       
   421             
       
   422 // End of File