upnp/upnpstack/controlpointbase/inc/upnpcpbdescriptionagent.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2007-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:  Declares ControlPoint Discovery class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CUPNPCPBDESCRIPTIONAGENT_H
       
    20 #define C_CUPNPCPBDESCRIPTIONAGENT_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CUpnpDevice;
       
    27 class CUpnpDispatcher;
       
    28 class CUpnpControlPoint;
       
    29 class CUpnpHttpMessage;
       
    30 class CUpnpCpbDeviceRepository;
       
    31 class CUpnpDeviceContentHandler;
       
    32 class CUpnpCpbDeviceDescription;
       
    33 class CUpnpCpbSimpleDeviceDescription;
       
    34 class CUpnpCpbEmbeddedDeviceDescription;
       
    35 class MUpnpCpbHttpMessageController;
       
    36 class CUpnpNotifyTimer;
       
    37 class MUpnpNotifyTimerObserver;
       
    38 class CUpnpContentHandlersController;
       
    39 
       
    40 /**
       
    41  * Mediator class handling whole discovery process.
       
    42  * It gets device description and decides how it should be treated
       
    43  * and how to discorery it.
       
    44  *
       
    45  * @lib controlpointbase.lib
       
    46  * @since S60 v5.0
       
    47  */
       
    48 NONSHARABLE_CLASS( CUpnpCpbDescriptionAgent ) : public CBase, public MUpnpNotifyTimerObserver
       
    49     {
       
    50     public:
       
    51     /**
       
    52      * Two-phased constructor
       
    53      * @since S60 v5.0
       
    54      */
       
    55     static CUpnpCpbDescriptionAgent* CUpnpCpbDescriptionAgent::NewL(
       
    56             CUpnpControlPoint& aBaseCP,
       
    57             MUpnpCpbHttpMessageController& aMessanger,
       
    58             CUpnpCpbDeviceRepository& aRepository);
       
    59 
       
    60     /**
       
    61      * Destructor
       
    62      * @since S60 v5.0
       
    63      */
       
    64     ~CUpnpCpbDescriptionAgent();
       
    65 
       
    66      /**
       
    67       * New device found.
       
    68       *
       
    69       * @since S60 v5.0
       
    70       * @param aDevice The target device.
       
    71       */
       
    72     void DeviceAliveNotificationL( CUpnpDevice* aDevice );
       
    73 
       
    74      /**
       
    75       * Process device message
       
    76       * @param aHttpMessage Message to process
       
    77       */
       
    78     void ProcessDeviceMessageL(CUpnpHttpMessage* aHttpMessage);
       
    79 
       
    80     /**
       
    81       * Process service message
       
    82       * @param aHttpMessage Message to process
       
    83       */
       
    84     void ProcessServiceMessageL(CUpnpHttpMessage* aHttpMessage);
       
    85 
       
    86     public: // From MNotifyTimerObserve
       
    87     /**
       
    88      * Callback function used to inform about the timer events
       
    89      */
       
    90     void TimerEventL( CUpnpNotifyTimer* aTimer );
       
    91 
       
    92     private:
       
    93     /**
       
    94      * Constructor
       
    95      * @since S60 v5.0
       
    96      */
       
    97     CUpnpCpbDescriptionAgent(
       
    98         CUpnpControlPoint& aBaseCP,
       
    99         MUpnpCpbHttpMessageController& aMessanger,
       
   100         CUpnpCpbDeviceRepository& aRepository);
       
   101 
       
   102     /**
       
   103      * Get next device description
       
   104      *
       
   105      * @since S60 v5.0
       
   106      */
       
   107     void DiscoverNextDeviceL();
       
   108 
       
   109     /**
       
   110      * Get device description
       
   111      *
       
   112      * @since S60 v5.0
       
   113      * @param aDevice The target device.
       
   114      */
       
   115     void GetDeviceDescriptionL(CUpnpDevice* aDevice);
       
   116 
       
   117     /**
       
   118      * Choose description processor
       
   119      *
       
   120      * @since S60 v5.0
       
   121      * @param aDevice The target device.
       
   122      */
       
   123     void ChooseDesriptionProcesor(CUpnpDevice* aDevice);
       
   124 
       
   125     /**
       
   126      * Function processing disscovery result
       
   127      *
       
   128      * @since S60 v5.0
       
   129      * @param aResult result
       
   130      */
       
   131     void HandleDiscoveryResultL(TInt aResult);
       
   132 
       
   133     /**
       
   134      * Send stop ignoring message to MH
       
   135      *
       
   136      * @since S60 v5.0
       
   137      * @param aUuids Uuids that should not be filtered
       
   138      */
       
   139     void StopIgnoringUuidL(const TDesC8& aUuids);
       
   140 
       
   141     /**
       
   142      * Check if device is valid
       
   143      *
       
   144      * @since S60 v5.0
       
   145      * @param aDevice The target device.
       
   146      */
       
   147     TBool IsDeviceValid( CUpnpDevice* aDevice );
       
   148 
       
   149     /**
       
   150      * Copy results to repository
       
   151      *
       
   152      * @since S60 v5.0
       
   153      * @return ETrue when devices was copied
       
   154      */
       
   155     TBool CUpnpCpbDescriptionAgent::CopyResult();
       
   156 
       
   157     /**
       
   158      * Copy results to repository
       
   159      *
       
   160      * @since S60 v5.0
       
   161      */
       
   162     void CUpnpCpbDescriptionAgent::CopyResultL();
       
   163 
       
   164     /**
       
   165      * Report discovered devices to the client
       
   166      *
       
   167      * @since S60 v5.0
       
   168      */
       
   169     void ReportDiscoveredDevicesL();
       
   170 
       
   171     /**
       
   172      * Second phase constructor
       
   173      * @since S60 v5.0
       
   174      */
       
   175     void ConstructL();
       
   176 
       
   177     /**
       
   178      * Find network for device tree
       
   179      *
       
   180      * @since S60 v5.0
       
   181      */
       
   182     CUpnpDevice::TUpnpDeviceNetwork
       
   183         FindNetworkForDeviceTree( RPointerArray<CUpnpDevice>& aDevices );
       
   184 
       
   185 
       
   186     /**
       
   187      * Construct and validate device tree
       
   188      *
       
   189      * @since S60 v5.0
       
   190      */
       
   191     void ConstructAndValidateDeviceTreeL( const TDesC8& aDeviceDescXml,
       
   192                                           const TInetAddr& aAddr,
       
   193                                           const TDesC8& aDeviceDescPath );
       
   194 
       
   195     /**
       
   196      * This function sets UrlBase value based on the relative path of the description URL.
       
   197      */
       
   198     void SetUrlBaseL( CUpnpDevice* aDevice, const TDesC8& aPath );
       
   199 
       
   200 
       
   201     private:
       
   202     // Dispatcher module is responsible for the messaging, not owned
       
   203     CUpnpControlPoint& iBaseCP;
       
   204     // Massenger handling HTTP messages. NOT OWNED
       
   205     MUpnpCpbHttpMessageController& iMessanger;
       
   206     // Ropository with devices, DO NOT DELETE
       
   207     CUpnpCpbDeviceRepository& iDeviceRepository;
       
   208 
       
   209     // Sax parsers for device description
       
   210     CUpnpContentHandlersController* iSaxController;
       
   211     // List with incoming devices
       
   212     RPointerArray<CUpnpDevice> iIncomingDevices;
       
   213     // Flag is TRUE when discovery is in progress
       
   214     TBool iPendingDiscovery;
       
   215     // Discovery timer
       
   216     CUpnpNotifyTimer* iTimer;
       
   217     // Root device uuid
       
   218     RBuf8 iUuid;
       
   219     // Current session number
       
   220     TInt iDescriptionSession;
       
   221 
       
   222     // Strategy used for current device, DO NOT DELETE
       
   223     CUpnpCpbDeviceDescription* iDiscoveryEngine;
       
   224     // Strategy used for simple devices
       
   225     CUpnpCpbSimpleDeviceDescription* iSimpleDiscoveryEngine;
       
   226     // Strategy used for embedded devices
       
   227     CUpnpCpbEmbeddedDeviceDescription* iEmbeddedDiscoveryEngine;
       
   228 
       
   229     };
       
   230 
       
   231 #endif // C_CUPNPCPBDESCRIPTIONAGENT_H
       
   232 //  End of File