upnpavcontrolpoint/avcpengine/inc/upnpavcpmanager.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /** @file
       
     2 * Copyright (c) 2005-2006 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:  Class comunicates with MSs
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CUPNPAVCPMANAGER_H
       
    20 #define C_CUPNPAVCPMANAGER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "upnpavcontrolpoint.h"
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class MUpnpResponseHandler;
       
    27 class MUpnpHttpResponseHandler;
       
    28 class CUpnpPathResolver;
       
    29 class CUpnpAVCPEngineSession;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 /**
       
    33 * Class implements (derive CUpnpAVControlPoint).
       
    34 * It provides way to send SOAP action, HTTP request, 
       
    35 * receive notification about responses also support eventing phase.
       
    36 * Additionally class keeps path resolvers for each MS (if it is needed).
       
    37 *
       
    38 *  @since Series 60 3.1
       
    39 */
       
    40 class CUpnpAVCPManager : public CUpnpAVControlPoint
       
    41 	{	
       
    42 	public:
       
    43 		/**
       
    44 		* Two-phased constructor.
       
    45 		*/		
       
    46 		static CUpnpAVCPManager* NewL();
       
    47 		/**
       
    48 		* Destructor.
       
    49 		*/		        
       
    50 		~CUpnpAVCPManager();
       
    51  		/**
       
    52 		* Get unique command id
       
    53 		* 
       
    54 		* @return command id
       
    55 		*/		
       
    56 		TInt NewCommandId();
       
    57  		/**
       
    58  		* Register a observer for receive notification about SOAP responses
       
    59  		*
       
    60  		* @param aHandler class implemented observer
       
    61  		*/
       
    62 		void RegisterForAction(MUpnpResponseHandler& aHandler);
       
    63  		/**
       
    64  		* Register a observer for receive notification about HTTP responses
       
    65  		*
       
    66  		* @param aHandler class implemented observer
       
    67  		*/        
       
    68 		void RegisterForHttp(MUpnpHttpResponseHandler& aHandler);        
       
    69  		/**
       
    70  		* Unregister a observer for receive notification about HTTP responses
       
    71  		*
       
    72  		* @param aHandler class implemented observer
       
    73  		*/        
       
    74 		void UnregisterForHttp(MUpnpHttpResponseHandler& aHandler);                
       
    75 	    /**
       
    76 	    * Return path resolver.
       
    77 	    * If path resolver was created, return instance, otherwise create a new one, 
       
    78 	    * subsribe for events.
       
    79 	    * Parameter aSession is used for managing life time of resolver. 
       
    80 	    * if all session used resolver has been closed, resolver is doestoyed.
       
    81 	    *
       
    82 	    * @param aUUID UDN of MS
       
    83 	    * aSession server-side session
       
    84 	    */            
       
    85 		CUpnpPathResolver& PathResolverL(const TDesC8& aUUID, CUpnpAVCPEngineSession* aSession);
       
    86 	    /**
       
    87 	    * Perform cleanup after closing server-side session.
       
    88 	    * it checks whether it was the last session used resolver and
       
    89 	    * destroy resolver if it was true.
       
    90 	    */    
       
    91 		void CleanupSessionL( CUpnpAVCPEngineSession* aSession);        
       
    92 		           
       
    93 	private: 	// Method from CUpnpAVControlPoint
       
    94 		/**
       
    95 		* From CUpnpAVControlPoint handles HTTP messages.
       
    96 		* @since Series 60 2.0
       
    97 		* @param aMessage Incoming HTTP message.
       
    98 		*/
       
    99 		void HttpResponseReceivedL(CUpnpHttpMessage* aMessage);
       
   100 		/**
       
   101 		* From CUpnpAVControlPoint handles actions' responses.
       
   102 		* @since Series 60 2.0
       
   103 		* @param aMessage Incoming HTTP message.
       
   104 		*/
       
   105 		void ActionResponseReceivedL(CUpnpAction* aAction);        
       
   106 		/**
       
   107 		* From CUpnpAVControlPoint handles events (as a response for SUBSCRIBE).
       
   108 		* @since Series 60 2.0
       
   109 		* @param aMessage Incoming HTTP message.
       
   110 		*/        
       
   111 		void StateUpdatedL(CUpnpService*  aService);
       
   112 		/**
       
   113 		* From CUpnpAVControlPoint handles UPnP device discoveries.
       
   114 		* @since Series 60 2.0
       
   115 		* @param aDevice Device that is discovered.
       
   116 		*/
       
   117 		void DeviceDiscoveredL(CUpnpDevice* aDevice);
       
   118 		/**
       
   119 		* From CUpnpAVControlPoint handles UPnP device disappears.
       
   120 		* @since Series 60 2.0
       
   121 		* @param aDevice Device that disappeared.
       
   122 		*/
       
   123 		void DeviceDisappearedL(CUpnpDevice* aDevice);
       
   124 
       
   125 	private:
       
   126 		/**
       
   127 		* C++ default constructor.
       
   128 		*/	
       
   129 		CUpnpAVCPManager(MUpnpAVControlPointObserver* aObserver);
       
   130 		/**
       
   131 		* Symbian 2nd phase constructor.
       
   132 		*/		        
       
   133 		void ConstructL();       
       
   134     /**
       
   135     * Return index of action handler for specific session id
       
   136     * 
       
   137     * @return index if found, else KErrNotFound
       
   138     */    
       
   139 		TInt HandlerBySessionId(TInt aSessionId);
       
   140     /**
       
   141     * Return index of HTTP handler for specific session id
       
   142     * 
       
   143     * @return index if found, else KErrNotFound
       
   144     */            
       
   145 		TInt HttpHandlerBySessionId(TInt aSessionId);   
       
   146 		                          
       
   147 	private: // Data
       
   148 		// last command id
       
   149 		TInt iLastCommandId;
       
   150 		// array of observers registered for SOAP action
       
   151 		RPointerArray<MUpnpResponseHandler> iPendingHandlers;
       
   152 		// array of observer registered for HTTP response
       
   153 		RPointerArray<MUpnpHttpResponseHandler> iHttpPendingHandlers;
       
   154 		// array of path resolvers
       
   155 		RPointerArray<CUpnpPathResolver> iPathResolvers;
       
   156     };
       
   157 
       
   158 #endif  //C_CUPNPAVCPMANAGER_H
       
   159