browserutilities/downloadmgr/DownloadMgrClntSrv/inc/DownloadMgrServer.h
changeset 0 dd21522fd290
child 26 cb62a4f66ebe
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:  This file contains the definition of the Download Mgr Server.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __DOWNLOADMGR_SERVER_H__
       
    20 #define __DOWNLOADMGR_SERVER_H__
       
    21 
       
    22 //  INCLUDES
       
    23 #include <HttpDownloadManagerServerEngine.h>
       
    24 #include <e32base.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CHttpClientAppInstance;
       
    28 class CHttpDownload;
       
    29 class CDownloadSubSession;
       
    30 class CDownloadMgrEventQueue;
       
    31 class CDefaultAttrib;
       
    32 class CDownloadMgrServer;
       
    33 
       
    34 // DATA TYPES
       
    35 // panic reasons
       
    36 enum TDownloadMgrSvrPanic
       
    37 	{
       
    38 	EBadRequest,
       
    39 	EBadDescriptor,
       
    40 	EDescriptorNonNumeric,
       
    41 	EMainSchedulerError,
       
    42 	ESvrCreateServer,
       
    43 	ECreateTrapCleanup,
       
    44 	EBadCounterRemove, 
       
    45 	EBadSubsessionHandle,
       
    46     EMultipleInitDownloadEvent
       
    47 	};
       
    48 
       
    49 // CLASS DECLARATION
       
    50 /**
       
    51 *  Download manager server's shutdown timer.
       
    52 */
       
    53 NONSHARABLE_CLASS( CDownloadMgrShutdown ) : public CActive
       
    54     {
       
    55     public: // Constructors and destructor
       
    56 
       
    57         /**
       
    58         * Two-phased constructor.
       
    59         */
       
    60         static CDownloadMgrShutdown* NewL( CDownloadMgrServer* aServer );
       
    61 
       
    62         /**
       
    63         * Destructor.
       
    64         */
       
    65         ~CDownloadMgrShutdown();
       
    66 
       
    67     private:
       
    68 
       
    69         /**
       
    70         * C++ default constructor.
       
    71         */
       
    72         CDownloadMgrShutdown( CDownloadMgrServer* aServer );
       
    73 
       
    74         /**
       
    75         * Default Symbian 2nd phase constructor .
       
    76         */
       
    77         void ConstructL();
       
    78 
       
    79     public: // New functions
       
    80 
       
    81         /**
       
    82         * Starts the timer.
       
    83         * @param 
       
    84         * @return
       
    85         */
       
    86         void Start();
       
    87 
       
    88     private: // From CActive
       
    89 
       
    90         /**
       
    91         * Cancels the timer.
       
    92         * @param 
       
    93         * @return
       
    94         */
       
    95         void DoCancel();
       
    96         /**
       
    97         * Handles an active object’s request completion event.
       
    98         * @param 
       
    99         * @return
       
   100         */
       
   101         void RunL();
       
   102 
       
   103     private: // Data
       
   104 
       
   105         RTimer              iTimer;
       
   106         CDownloadMgrServer* iServer;
       
   107     };
       
   108 
       
   109 /**
       
   110 *  Download manager server.
       
   111 */
       
   112 NONSHARABLE_CLASS( CDownloadMgrServer ) : public CPolicyServer
       
   113 
       
   114 	{
       
   115     public:  // Constructors and destructor
       
   116         
       
   117         /**
       
   118         * Two-phased constructor.
       
   119         */
       
   120         static CDownloadMgrServer* NewL();
       
   121 
       
   122         /**
       
   123         * Destructor.
       
   124         */
       
   125         ~CDownloadMgrServer();
       
   126 
       
   127     private:
       
   128 
       
   129         /**
       
   130         * C++ default constructor.
       
   131         */
       
   132         CDownloadMgrServer();
       
   133 
       
   134         /**
       
   135         * Default Symbian 2nd phase constructor .
       
   136         */
       
   137         void ConstructL();
       
   138 
       
   139     public: // From CServer2
       
   140         
       
   141         /**
       
   142         * Creates a server-side client session object.
       
   143         * @param aVersion Version information supplied by the client. 
       
   144         * @return A pointer to the newly created server-side client session.
       
   145         */
       
   146         CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
       
   147 
       
   148     public: // New functions
       
   149 
       
   150         /**
       
   151         * Creates the object container.
       
   152         * @param -
       
   153         * @return A pointer to the newly created CObjectCon.
       
   154         */
       
   155         CObjectCon* NewContainerL();
       
   156 
       
   157         /**
       
   158         * Removes the specified object container from this container index 
       
   159         * and deletes it.
       
   160         * @param aCon A pointer to the object container to be removed.
       
   161         * @return None.
       
   162         */
       
   163         void RemoveContainer( CObjectCon* aCon );
       
   164 
       
   165         /**
       
   166         * Create Client App Instance owned by CDownloadMgrSession.
       
   167         * @param aAppUid app uid of the cleant
       
   168         * @param aGetAllPendingDownloads
       
   169         * @return A pointer to the newly created CHttpClientAppInstance.
       
   170         */
       
   171         CHttpClientAppInstance* CreateNewClientAppInstanceL( 
       
   172                                         TUint32 aAppUid, 
       
   173                                         MDownloadStateObserver& aObserver, 
       
   174                                         TBool aGetAllPendingDownloads );
       
   175 
       
   176         /**
       
   177         * Closes Client App Instance owned by CDownloadMgrSession.
       
   178         * @param aAppInst client app instance
       
   179         * @return None.
       
   180         */
       
   181         void CloseClientInstance( CHttpClientAppInstance* aAppInst );
       
   182 
       
   183         /**
       
   184         * Keeps count of client sessions. Cancels shutdown timer.
       
   185         * @param -
       
   186         * @return None.
       
   187         */
       
   188         void IcrementSessions();
       
   189 
       
   190         /**
       
   191         * Keeps count of client sessions. Starts shutdown timer if needed.
       
   192         * @param -
       
   193         * @return None.
       
   194         */
       
   195         void DecrementSessions();
       
   196         
       
   197         /**
       
   198         * Generates and returns a unique session id
       
   199         */
       
   200         TInt NextSessionId();
       
   201 
       
   202         /**
       
   203         * returns number of active sessions
       
   204         */
       
   205 		TInt SessionsCount() {return iSessionCount;}
       
   206 
       
   207     public:
       
   208 
       
   209         /**
       
   210         * Panics the server thread associated with this session.
       
   211         * @param aPanic The panic number
       
   212         * @return None.
       
   213         */
       
   214         static void PanicServer( TDownloadMgrSvrPanic aPanic );
       
   215 
       
   216         /**
       
   217         * Returns the number of active download in the engine. 
       
   218         * @since Series 60 v2.8
       
   219         * @param ?arg1 ?description
       
   220         * @return ?description
       
   221         */
       
   222         TInt ActiveDownloads() const;
       
   223 
       
   224     private:     // Data
       
   225 
       
   226         // A container for object containers
       
   227         CObjectConIx*                     iContainerIndex; ///< Owned.
       
   228         // The Download Mgr Server Engine
       
   229         CHttpDownloadManagerServerEngine* iDmEngine; ///< Owned.
       
   230         // The number of sessions
       
   231         TInt                              iSessionCount;
       
   232         // Shutdown timer
       
   233         CDownloadMgrShutdown*             iShutdown; ///< Owned.
       
   234         // next unique session id
       
   235         TInt                              iNextSessionId;
       
   236 
       
   237     public:     // Friend classes
       
   238 
       
   239         friend class CHttpDownloadManagerServerEngine;
       
   240 	};
       
   241 
       
   242 /**
       
   243 *  This class represents the server side client app instance.
       
   244 */
       
   245 NONSHARABLE_CLASS( CDownloadMgrSession ) :
       
   246                             public CSession2,
       
   247                             public MDownloadStateObserver
       
   248 	{
       
   249 
       
   250     public:  // Constructors and destructor
       
   251         
       
   252         /**
       
   253         * Two-phased constructor.
       
   254         */
       
   255         static CDownloadMgrSession* NewL( CDownloadMgrServer* aServer );
       
   256 
       
   257         /**
       
   258         * Destructor.
       
   259         */
       
   260         ~CDownloadMgrSession();
       
   261 
       
   262     private:
       
   263 
       
   264         /**
       
   265         * C++ default constructor.
       
   266         */
       
   267         CDownloadMgrSession();
       
   268 
       
   269         /**
       
   270         * Default Symbian 2nd phase constructor.
       
   271         */
       
   272         void ConstructL( CDownloadMgrServer* aServer) ;
       
   273 
       
   274     public: // New functions
       
   275 
       
   276         /**
       
   277         * Returns the subsession identified by the handle.
       
   278         * @param aHandle the handle number that represents 
       
   279         * the subsession in the object index.
       
   280         * @return None.
       
   281         */
       
   282         CDownloadSubSession* DownloadFromHandle( TUint aHandle );
       
   283 
       
   284         /**
       
   285         * Dispatch request.
       
   286         * @param aMessage The message containing the client request
       
   287         * @return None.
       
   288         */
       
   289         void DispatchMessageL( const RMessage2& aMessage );
       
   290 
       
   291         /**
       
   292         * Sets the current message.
       
   293         * @param aMessage The message containing the client request
       
   294         * @return None.
       
   295         */
       
   296         void SetCurrentMessage( const RMessage2& aMessage );
       
   297 
       
   298         /**
       
   299         * Gets the current message.
       
   300         * @param -
       
   301         * @return The current message.
       
   302         */
       
   303         const RMessage2& CurrentMessage() const;
       
   304 
       
   305         /**
       
   306         * Creates a new download and subsession.
       
   307         * Writes the handle of the subsession to the client's address space
       
   308         * @param -
       
   309         * @return None.
       
   310         */
       
   311         void NewDownloadL();
       
   312 
       
   313         /**
       
   314         * Attach this session to the client, writes the handle of the 
       
   315         * current downloads to the client's address space.
       
   316         * @param -
       
   317         * @return None.
       
   318         */
       
   319         void DownloadMgrAttachL();
       
   320 
       
   321         /**
       
   322         * Attach a client to an existing download (PD download) 
       
   323         * @param -
       
   324         * @return None.
       
   325         */        
       
   326         void AttachToDownloadL();
       
   327 
       
   328         /**
       
   329         * Create a download subsession with CHttpDownload.
       
   330         * @param aDownload 
       
   331         * @param aDefAttrib - indicates if default setting attrib is needed
       
   332         * @return None.
       
   333         */
       
   334         void CreateDownloadL( CHttpDownload* aDownload, TBool aDefAttrib = EFalse );
       
   335 
       
   336         /**
       
   337         * Attach a download subsession to the client.
       
   338         * @param -
       
   339         * @return None.
       
   340         */
       
   341         void DownloadAttachL();
       
   342 
       
   343         /**
       
   344         * Delete the download subsession identified by the handle.
       
   345         * @param aHandle the handle number that represents 
       
   346         * the subsession in the object index.
       
   347         * @return None.
       
   348         */
       
   349         void DeleteDownload( TUint aHandle );
       
   350         
       
   351         /**
       
   352         * Panics the client thread associated with this session.
       
   353         * @param aPanic The panic number
       
   354         * @return None.
       
   355         */
       
   356         void PanicClient( TInt aPanic ) const;
       
   357 
       
   358 		/**
       
   359 		* Pauses all download.
       
   360 		* @param -
       
   361         * @return None.
       
   362 		*/
       
   363         void PauseAllL();
       
   364 
       
   365 		/**
       
   366 		* Starts all download.
       
   367 		* @param -
       
   368         * @return None.
       
   369 		*/
       
   370         void StartAllL();
       
   371 
       
   372 		/**
       
   373 		* Resets all download.
       
   374 		* @param -
       
   375         * @return None.
       
   376 		*/
       
   377         void ResetAll();
       
   378 
       
   379 		/**
       
   380 		* Deletes all download.
       
   381 		* @param -
       
   382         * @return None.
       
   383 		*/
       
   384         void DeleteAll();
       
   385 
       
   386         /**
       
   387         * Disconnects the instance's connection and pauses all downloads.
       
   388         * @since Series 60 2.8
       
   389         * @return none
       
   390         */
       
   391         void Disconnect();
       
   392 
       
   393 		/**
       
   394 		* Sets the IAP to the app instance reading from the client's address space.
       
   395 		* @param -
       
   396         * @return None.
       
   397 		*/
       
   398         void SetIapIdL();
       
   399 
       
   400 		/**
       
   401 		* Gets the IAP from the app instace and write to the client's address space.
       
   402 		* @param -
       
   403         * @return None.
       
   404 		*/
       
   405         void GetIapId();
       
   406 
       
   407 		/**
       
   408 		* Copies data from an 8 bit descriptor in the server address space 
       
   409         * to the client thread’s address space.
       
   410 		* @param aParam This is a value between 0 and 3 and indicates 
       
   411         * which of the four arguments in the original client message 
       
   412         * contains the pointer to the descriptor.
       
   413         * @param aMessage This is the message of which param is set.
       
   414 		* @param An 8 bit descriptor in the server address space.
       
   415         * @return None.
       
   416 		*/
       
   417         void Write( TInt aParam, RMessage2 aMessage, TDesC8& aDes );
       
   418 
       
   419 		/**
       
   420 		* Copies data from an 8 bit descriptor in the server address space 
       
   421         * to the client thread’s address space.
       
   422 		* @param aParam This is a value between 0 and 3 and indicates 
       
   423         * which of the four arguments in the original client message 
       
   424         * contains the pointer to the descriptor.
       
   425         * @param aMessage This is the message of which param is set.
       
   426 		* @param A 16 bit descriptor in the server address space.
       
   427         * @return None.
       
   428 		*/
       
   429         void Write( TInt aParam, RMessage2 aMessage, TDesC16& aDes );
       
   430 
       
   431 		/**
       
   432 		* Copies data from the client thread’s address space into an 8 bit 
       
   433         * descriptor in the server address space.
       
   434 		* @param aParam This is a value between 0 and 3 and indicates 
       
   435         * which of the four arguments in the original client message 
       
   436         * contains the pointer to the descriptor.
       
   437 		* @param aDes An 8 bit descriptor in the server address space.
       
   438         * @return None.
       
   439 		*/
       
   440         void Read( TInt aParam, TPtr8& aDes );
       
   441 
       
   442 		/**
       
   443 		* Copies data from the client thread’s address space into an 8 bit 
       
   444         * descriptor in the server address space.
       
   445 		* @param aParam This is a value between 0 and 3 and indicates 
       
   446         * which of the four arguments in the original client message 
       
   447         * contains the pointer to the descriptor.
       
   448 		* @param aDes An 8 bit descriptor in the server address space.
       
   449         * @return None.
       
   450 		*/
       
   451         void Read( TInt aParam, TPtr16& aDes );
       
   452 
       
   453 		/**
       
   454 		* Creates the app instance we are representing if needed.
       
   455 		* @param aAppUid application uid
       
   456 		* @param None.
       
   457 		*/
       
   458         void CreateClientAppInstanceL( TUint32 aAppUid );
       
   459 
       
   460 		/**
       
   461 		* Copies unique handle in the server address space
       
   462         * to the client thread’s address space.
       
   463 		* @param aHandle the handle number that represents 
       
   464         * the subsession in the object index.
       
   465 		* @return None.
       
   466 		*/
       
   467         void WriteHandle( TInt aHandle );
       
   468 
       
   469         /**
       
   470         * Initializes the session's event handler.
       
   471         * @param aMessage the message which should be completed.
       
   472         * @return None.
       
   473         */
       
   474         void InitSessionEvent( const RMessage2& aMessage  );
       
   475 
       
   476         /**
       
   477         * Cancels the moved event handler.
       
   478         * @param -
       
   479         * @return None.
       
   480         */
       
   481         void CancelMovedEvent();
       
   482 
       
   483         /**
       
   484         * Creates a new subsession with download and send event to the client.
       
   485         * @param -
       
   486         * @return ETrue, if event was requested and sent.
       
   487         */
       
   488         TBool CreateSubSessionAndSendEventL( CHttpDownload* aDownload,
       
   489                                              TInt32 aDownloadState,
       
   490                                              TInt32 aProgressState,
       
   491                                              TInt32 aMoIndex );
       
   492 
       
   493         /**
       
   494         * Removes download from the event queue.
       
   495         * @param aDownload
       
   496         * @return None.
       
   497         */
       
   498         void RemoveFromQueue( CHttpDownload* aDownload );
       
   499         
       
   500         /**
       
   501         * Return the session Id.
       
   502         * @return id of the session
       
   503         */
       
   504         TInt SessionId() const;
       
   505 
       
   506         /**
       
   507         * Return the client app instance.
       
   508         * @return client app instance
       
   509         */
       
   510         CHttpClientAppInstance* ClientAppInstance()const;
       
   511 
       
   512     public: // from MDownloadStateObserver
       
   513 
       
   514         /**
       
   515         * Indicates an event occoured by the download.
       
   516         * @param aDownload The download object which the event occured.
       
   517         * @return None.
       
   518         */
       
   519         void Event( CHttpDownload* aDownload, 
       
   520                     THttpDownloadState aDlState,
       
   521                     THttpProgressState aProgState,
       
   522                     TInt32 aMoIndex );
       
   523 
       
   524         /**
       
   525         *
       
   526         * @param aDownload The download object which the event occured.
       
   527         * @return None.
       
   528         */
       
   529         void SetComplete( TBool aComplete );
       
   530 
       
   531     protected:
       
   532 
       
   533         /**
       
   534         * Called if the event needs to be vompleted
       
   535         * @param aErrorStatus Leave code or KErrNone
       
   536         * @return None.
       
   537         */
       
   538         void EventComplete( TInt aErrorStatus );
       
   539 
       
   540         /**
       
   541 		* Initialize the session with the parameters got from client side.
       
   542         * Write the number of the attachable downloads to the
       
   543         * client's address space.
       
   544 		* @param -
       
   545         * @return None.
       
   546 		*/
       
   547         void InitializeL();
       
   548 
       
   549         /**
       
   550 		* Gets the value for a TInt attribute writing to the client's address space.
       
   551 		* @param -
       
   552         * @return None.
       
   553 		*/
       
   554 		void GetIntAttributeL();
       
   555 
       
   556         /**
       
   557 		* Gets the value for a TBool attribute writing to the client's address space.
       
   558 		* @param -
       
   559         * @return None.
       
   560 		*/
       
   561 		void GetBoolAttributeL();
       
   562 
       
   563 		/**
       
   564 		* Gets the value for a string attribute writing to the client's address space.
       
   565 		* @param -
       
   566         * @return None.
       
   567 		*/
       
   568 		void GetStringAttributeL();
       
   569 
       
   570 		/**
       
   571 		* Gets the value for a string attribute writing to the client's address space.
       
   572 		* @param -
       
   573         * @return None.
       
   574 		*/
       
   575 		void GetString8AttributeL();
       
   576 
       
   577         /**
       
   578 		* Sets the value for a TInt attribute reading from the client's address space.
       
   579 		* @param -
       
   580         * @return None.
       
   581 		*/
       
   582 		void SetIntAttributeL();
       
   583         
       
   584 		/**
       
   585 		* Sets the value for a TBool attribute reading from the client's address space.
       
   586 		* @param -
       
   587         * @return None.
       
   588 		*/
       
   589 	    void SetBoolAttributeL();
       
   590 		
       
   591 		/**
       
   592 		* Sets the value for a string attribute reading from the client's address space.
       
   593 		* @param -
       
   594         * @return None.
       
   595 		*/
       
   596 		void SetStringAttributeL();
       
   597 
       
   598 		/**
       
   599 		* Sets the value for a string attribute reading from the client's address space.
       
   600 		* @param -
       
   601         * @return None.
       
   602 		*/
       
   603 		void SetString8AttributeL();
       
   604 
       
   605     private:      // from CSession
       
   606 
       
   607         /**
       
   608         * Handles the servicing of client requests to the server..
       
   609         * @param aMessage The message containing the client request.
       
   610         * @return None.
       
   611         */
       
   612         void ServiceL( const RMessage2& aMessage );
       
   613 
       
   614     private:     // Data
       
   615 
       
   616         // To the current message
       
   617         RMessage2               iCurrentMessage;
       
   618         // Object container for this session
       
   619         CObjectCon*             iObjectContainer;   ///< Owned.
       
   620         // Object index which stores objects (CDownloadSubSession instances) 
       
   621         // for this session
       
   622         CObjectIx*              iObjectIx;          ///< Owned.
       
   623         // Pointer to owning server
       
   624         CDownloadMgrServer*     iDownloadMgrServer; ///< NOT Owned.
       
   625         // The client app instance which we are representing
       
   626         CHttpClientAppInstance* iClientAppInstance; ///< Owned.
       
   627         // Queue the events comes from the engine.
       
   628         CDownloadMgrEventQueue* iEventQueue;        ///< Owned.
       
   629         // Indicates if the request may be completed
       
   630         TBool                   iComplete;
       
   631         // Used by moved event handler, the message which should be completed.
       
   632         RMessage2               iEventMessage;  ///< NOT Owned.
       
   633         // Indicates the moved event is initialized.
       
   634         TBool                   iEvent;
       
   635         // Initialization parameters set by the client side
       
   636         TBool                   iIsMaster;
       
   637         // Unique id of the session
       
   638         TInt                    iSessionId;
       
   639 	};
       
   640 
       
   641 /**
       
   642 *  This class represents the server side download object.
       
   643 */
       
   644 NONSHARABLE_CLASS( CDownloadSubSession ) : public CObject
       
   645 	{
       
   646     public:  // Constructors and destructor
       
   647         
       
   648         /**
       
   649         * Two-phased constructor.
       
   650         */
       
   651         static CDownloadSubSession * NewL( CDownloadMgrSession* aSession,
       
   652                                            CHttpDownload* aDownload );
       
   653 
       
   654         /**
       
   655         * destructor.
       
   656         */
       
   657         ~CDownloadSubSession();
       
   658 
       
   659     private:
       
   660 
       
   661         /**
       
   662         * C++ default constructor.
       
   663         */
       
   664         CDownloadSubSession();
       
   665         
       
   666         /**
       
   667         * Default Symbian 2nd phase constructor.
       
   668         */
       
   669         void ConstructL( CDownloadMgrSession *aSession,
       
   670                          CHttpDownload* aDownload );
       
   671 
       
   672     public:    // New functions
       
   673 
       
   674         /**
       
   675         * Closes the subsession.
       
   676         * @param -
       
   677         * @return None.
       
   678         */
       
   679         void CloseDownload();
       
   680 
       
   681         /**
       
   682         * Closes the completed subsession.
       
   683         * @param -
       
   684         * @return None.
       
   685         */
       
   686         void CloseCompletedDownload();
       
   687 
       
   688         /**
       
   689         * Starts the download.
       
   690         * @param -
       
   691         * @return None.
       
   692         */
       
   693         void StartL();
       
   694 
       
   695         /**
       
   696         * Pauses the download.
       
   697         * @param -
       
   698         * @return None.
       
   699         */
       
   700         void PauseL();
       
   701 
       
   702         /**
       
   703         * Resets the download.
       
   704         * @param -
       
   705         * @return None.
       
   706         */
       
   707         void Reset();
       
   708 
       
   709         /**
       
   710         * Deletes the download.
       
   711         * @param -
       
   712         * @return None.
       
   713         */
       
   714         void Delete();
       
   715 
       
   716         /**
       
   717         * Moves the downloaded content.
       
   718         * @param -
       
   719         * @return None.
       
   720         */
       
   721         void MoveL();
       
   722 
       
   723         /**
       
   724         * Returns the current message - gotten from session.
       
   725         * @param  -
       
   726         * @return RMessage2& gotten from the session.
       
   727         */
       
   728         const RMessage2& Message() const;
       
   729 
       
   730         /**
       
   731         * Initializes the download's event handler.
       
   732         * @param aMessage the message which should be completed.
       
   733         * @return None.
       
   734         */
       
   735         void InitDownloadEvent( const RMessage2& aMessage  );
       
   736 
       
   737         /**
       
   738         * Cancels the download's event handler.
       
   739         * @param -
       
   740         * @return None.
       
   741         */
       
   742         void CancelDownloadEvent();
       
   743 
       
   744         /**
       
   745         * Indicates an event occoured by the download.
       
   746         * @param aDownloadState
       
   747         * @param aProgressState
       
   748         * @return TBool True if the event was sent.
       
   749         */
       
   750         TBool EventL( TInt32 aDownloadState, TInt32 aProgressState, TInt32 aMoIndex );
       
   751 
       
   752         /**
       
   753         * Called if a leave from the download is trapped
       
   754         * @param aError Leave code
       
   755         * @return None.
       
   756         */
       
   757         void OnError( TInt aError,
       
   758                       THttpDownloadMgrError aDlError = EGeneral );
       
   759 
       
   760         /**
       
   761         * Called if the event needs to be vompleted
       
   762         * @param aErrorStatus Leave code or KErrNone
       
   763         * @return None.
       
   764         */
       
   765         void EventComplete( TInt aErrorStatus );
       
   766 
       
   767         /**
       
   768 		* Gets the value for a TInt attribute writing to the client's address space.
       
   769 		* @param -
       
   770         * @return None.
       
   771 		*/
       
   772 		void GetIntAttributeL();
       
   773 
       
   774         /**
       
   775 		* Gets the value for a TBool attribute writing to the client's address space.
       
   776 		* @param -
       
   777         * @return None.
       
   778 		*/
       
   779 		void GetBoolAttributeL();
       
   780 
       
   781 		/**
       
   782 		* Gets the value for a string attribute writing to the client's address space.
       
   783 		* @param -
       
   784         * @return None.
       
   785 		*/
       
   786 		void GetStringAttributeL();
       
   787 
       
   788 		/**
       
   789 		* Gets the value for a string attribute writing to the client's address space.
       
   790 		* @param -
       
   791         * @return None.
       
   792 		*/
       
   793 		void GetString8AttributeL();
       
   794 
       
   795         /**
       
   796         * Gets the file handle from the download.
       
   797         */
       
   798         void GetFileHandleAttributeL();
       
   799 
       
   800         /**
       
   801 		* Sets the value for a TInt attribute reading from the client's address space.
       
   802 		* @param -
       
   803         * @return None.
       
   804 		*/
       
   805 		void SetIntAttributeL();
       
   806         
       
   807 		/**
       
   808 		* Sets the value for a TBool attribute reading from the client's address space.
       
   809 		* @param -
       
   810         * @return None.
       
   811 		*/
       
   812 	    void SetBoolAttributeL();
       
   813 		
       
   814 		/**
       
   815 		* Sets the value for a string attribute reading from the client's address space.
       
   816 		* @param -
       
   817         * @return None.
       
   818 		*/
       
   819 		void SetStringAttributeL();
       
   820 
       
   821 		/**
       
   822 		* Sets the value for a string attribute reading from the client's address space.
       
   823 		* @param -
       
   824         * @return None.
       
   825 		*/
       
   826 		void SetString8AttributeL();
       
   827 
       
   828         /**
       
   829         * Sets the file handle for the download.
       
   830         */
       
   831         void SetFileHandleAttributeL();
       
   832         
       
   833         /**
       
   834         * Sets the download data (media info).
       
   835         */
       
   836         void SetDownloadDataAttributeL();
       
   837         
       
   838         /**
       
   839         * Sets the media object data (track info).
       
   840         */
       
   841         void SetTrackDataAttributeL();
       
   842         
       
   843 		/**
       
   844 		* Sets default attributes.
       
   845 		* @param -
       
   846         * @return None.
       
   847 		*/
       
   848         void SetDefAttributesL();
       
   849 
       
   850 		/**
       
   851 		* Copies data from an 8 bit descriptor in the server address space 
       
   852         * to the client thread’s address space.
       
   853 		* @param aParam This is a value between 0 and 3 and indicates 
       
   854         * which of the four arguments in the original client message 
       
   855         * contains the pointer to the descriptor.
       
   856 		* @param A 16 bit descriptor in the server address space.
       
   857         * @return None.
       
   858 		*/
       
   859         void Write( TInt aParam, TDesC8& aDes );
       
   860 
       
   861 		/**
       
   862 		* Copies data from an 8 bit descriptor in the server address space 
       
   863         * to the client thread’s address space.
       
   864 		* @param aParam This is a value between 0 and 3 and indicates 
       
   865         * which of the four arguments in the original client message 
       
   866         * contains the pointer to the descriptor.
       
   867 		* @param An 8 bit descriptor in the server address space.
       
   868         * @return None.
       
   869 		*/
       
   870         void Write( TInt aParam, TDesC16& aDes );
       
   871 
       
   872 		/**
       
   873 		* Copies data from the client thread’s address space into an 8 bit 
       
   874         * descriptor in the server address space.
       
   875 		* @param aParam This is a value between 0 and 3 and indicates 
       
   876         * which of the four arguments in the original client message 
       
   877         * contains the pointer to the descriptor.
       
   878 		* @param aDes A 16 bit descriptor in the server address space.
       
   879         * @return None.
       
   880 		*/
       
   881         void Read( TInt aParam, TDes8& aDes );
       
   882 
       
   883 		/**
       
   884 		* Copies data from the client thread’s address space into an 8 bit 
       
   885         * descriptor in the server address space.
       
   886 		* @param aPtr A pointer to a valid address within the client 
       
   887         * thread’s address space.
       
   888 		* @param aDes An 8 bit descriptor in the server address space.
       
   889         * @return None.
       
   890 		*/
       
   891         void Read( TInt aParam, TDes16& aDes );
       
   892 
       
   893 		/**
       
   894 		* Checks the identity of the download objects.
       
   895 		* @param aDownload The download object.
       
   896 		* @return True if the specified aDownload equals with the represented one.
       
   897 		*/
       
   898         TBool IsDownload( CHttpDownload* aDownload );
       
   899 
       
   900 		/**
       
   901 		* Returns a pointer to the download.
       
   902 		* @param .
       
   903 		* @return CHttpDownload*.
       
   904 		*/
       
   905         CHttpDownload* Download();
       
   906 
       
   907 		/**
       
   908 		* Returns the handle number.
       
   909 		* @param -
       
   910 		* @return TUint.
       
   911 		*/
       
   912         TUint Handle();
       
   913 
       
   914 		/**
       
   915 		* Sets the handle number.
       
   916 		* @param aHandle handle number.
       
   917 		* @return None.
       
   918 		*/
       
   919         void SetHandle( TUint aHandle );
       
   920 
       
   921         /**
       
   922         * Dispatches download message
       
   923         * @since Series v2.8 Series60
       
   924         * @param aMessage FThe current message.
       
   925         * @return none. Leaves on error.
       
   926         */
       
   927         void DispatchMessageL( const RMessage2& aMessage );
       
   928 
       
   929 		/**
       
   930 		* Buffers attributes which need when a client deletes download.
       
   931 		* @param None.
       
   932         * @return None.
       
   933 		*/
       
   934         void BufferAttributesL();
       
   935 
       
   936 		/**
       
   937 		* Create a package for attributes. Part of IPC optimalization.
       
   938 		* @param aBuffered - indicates that all the buffered attributes needs to be passed.
       
   939         * @return HBufC8*.
       
   940 		*/
       
   941         HBufC8* CreateAttribPackL( TBool aBuffered = EFalse);
       
   942 
       
   943     protected:   // Data
       
   944         // Session owning us.
       
   945         CDownloadMgrSession* iSession; // NOT Owned.
       
   946     
       
   947     private:     // Data
       
   948         // The download we are representing
       
   949         CHttpDownload* iDownload; ///< NOT Owned.
       
   950         // Used by event handler, the message which should be completed.
       
   951         RMessage2      iMessage;  ///< NOT Owned.
       
   952         // Indicates the event is initialized.
       
   953         TBool          iEvent;
       
   954         // Unique handle of the subsession
       
   955         TUint          iHandle;
       
   956         
       
   957         CArrayPtrFlat< CDefaultAttrib >* iAttribs;
       
   958 	};
       
   959 
       
   960 #endif /* __DOWNLOADMGR_SERVER_H__ */