upnp/upnpstack_plat/upnp_common_api/inc/upnpservice.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     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:  Implements the CUpnpService class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CUPNPSERVICE_H
       
    20 #define C_CUPNPSERVICE_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <e32des8.h>
       
    26 #include "upnpaction.h"
       
    27 #include "upnpstatevariable.h"
       
    28 #include "upnpdispatchercustomer.h"
       
    29 #include "upnphttpmessage.h"
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 _LIT8( KAction,     "action" );
       
    34 _LIT8( KStateVariable,  "stateVariable" );
       
    35 _LIT8( KProperty,   "property" );
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 
       
    39 class CUpnpDevice;
       
    40 class CUpnpAction;
       
    41 class CUpnpServiceImplementation;
       
    42 class CUpnpDispatcher;
       
    43 class CUpnpHttpMessage;
       
    44 class CUpnpGenaMessage;
       
    45 class MUpnpContentDirectoryDataFinder; 
       
    46 
       
    47 // CLASS DECLARATION
       
    48 
       
    49 /**
       
    50 *  SCPD handling.
       
    51 *  This is a data class containing the data of the service description
       
    52 *  (SCPD). This data consists of actions, their arguments and state variables.
       
    53 *
       
    54 *  @since Series60 2.6
       
    55 */
       
    56 class CUpnpService : public CBase
       
    57 {
       
    58 public: // Constructors and destructor
       
    59 
       
    60     IMPORT_C TBool IsAdded();
       
    61     
       
    62     /** Two-phased constructor, called from other NewL functions.
       
    63     * Only for internal usage. 
       
    64     * @param aDescription Content of the service description.
       
    65     * @param aServiceType Type of the service.
       
    66     * @param aDevice Parent device.
       
    67     */
       
    68     IMPORT_C static CUpnpService* NewL( const TDesC8& aDescription, 
       
    69                                         const TDesC8& aServiceType, 
       
    70                                         CUpnpDevice& aDevice );
       
    71                         
       
    72     /** 
       
    73     * Destructor
       
    74     */
       
    75     IMPORT_C virtual ~CUpnpService();
       
    76         
       
    77 public: // New functions
       
    78 
       
    79   
       
    80     /**
       
    81     * Sets the value of a state variable. If no such named state variable
       
    82     * found, ignore.
       
    83     * @since Series60 2.6
       
    84     * @param aName Name of the variable (in SCPD).
       
    85     * @param aValue Requested value for state variable.
       
    86     */
       
    87     IMPORT_C void SetStateVariableL( const TDesC8& aName, 
       
    88                      const TDesC8& aValue );
       
    89 
       
    90     /**
       
    91     * Returns the requested state variable
       
    92     * @since Series60 2.6
       
    93     * @param aName Name of the variable (in SCPD).
       
    94     * @return CUpnpStateVariable*. Points to NULL if state variable not found.
       
    95     */
       
    96     IMPORT_C CUpnpStateVariable* StateVariable( const TDesC8& aName );
       
    97     
       
    98     /**
       
    99     * Get service type of this (local or remote) service
       
   100     * @since Series60 2.6
       
   101     * @return Service type.
       
   102     */
       
   103     IMPORT_C const TDesC8& ServiceType();
       
   104     
       
   105     void SetServiceTypeL( const TDesC8& aSercviceType );
       
   106     /**
       
   107     * Get message dispatching path. For internal use only. 
       
   108     * @since Series60 2.6
       
   109     * @return path
       
   110     */
       
   111     IMPORT_C const TDesC8& Path();
       
   112 	
       
   113     void SetPathL( const TDesC8& aPath );
       
   114         
       
   115     /**
       
   116     * Get parent device of this service. 
       
   117     * @since Series60 2.6
       
   118     * @return Parent device.
       
   119     */
       
   120     IMPORT_C CUpnpDevice& Device();
       
   121    
       
   122     /**
       
   123     * For internal use. Get subscription url address of this service.  
       
   124     * To make subscriptions use CUpnpControlPoint::SubscribeL( CUpnpService* )
       
   125     * @since Series60 2.6
       
   126     * @return subscription url address
       
   127     */
       
   128     IMPORT_C const TPtrC8 SubscriptionUrl();
       
   129     
       
   130     /**
       
   131     * For internal use. Set subscription url address of this service.  
       
   132     * To make subscriptions use CUpnpControlPoint::SubscribeL( CUpnpService* )    
       
   133     * @param aUrl subscription url address, ownership is passed
       
   134     */
       
   135     IMPORT_C void SetSubscriptionUrl(HBufC8* aUrl);
       
   136 
       
   137     /**
       
   138     * For internal use. Get control url address of this service.  
       
   139     * @return control url address
       
   140     */
       
   141     IMPORT_C const TPtrC8 ControlUrl();
       
   142         
       
   143     /**
       
   144     * For internal use. Set control url address of this service.  
       
   145     * @param aUrl control url address, ownership is passed
       
   146     */
       
   147     IMPORT_C void SetControlUrl(HBufC8* aUrl);
       
   148     
       
   149     /**
       
   150     * For internal use. Get service url address of this service.  
       
   151     * @return control url address
       
   152     */
       
   153     IMPORT_C const TPtrC8 ServiceDescriptionUrl();
       
   154     
       
   155     /**
       
   156     * For internal use. Set control url address of this service.  
       
   157     * @param aUrl service url address, ownership is passed
       
   158     */
       
   159     IMPORT_C void SetServiceDescriptionUrl(HBufC8* aUrl);
       
   160         
       
   161     /**
       
   162     * Get IP address of this (local or remote) service. 
       
   163     * @since Series60 2.6
       
   164     * @return address
       
   165     */
       
   166     IMPORT_C TInetAddr Address();
       
   167     
       
   168    
       
   169     
       
   170     /**
       
   171     * Returns an action with the given name. If such action found,
       
   172     * the pointer aAction is set to that action. 
       
   173     * @since Series60 2.6
       
   174     * @param aAction XML element where action is placed.
       
   175     * @param aActionName Name of the action.
       
   176     * @return ETrue, if action is found.
       
   177     */
       
   178     IMPORT_C TBool GetAction( CUpnpAction*& aAction, 
       
   179                   const TDesC8& aActionName );
       
   180     
       
   181     /**
       
   182     * For internal use. Sets the aActionList pointer to point to
       
   183     * list of XML elements describing actions.
       
   184     * @since Series60 2.6
       
   185     * @param aActionList pointer array containing the action list    
       
   186     */
       
   187     IMPORT_C void GetActionList( RPointerArray<CUpnpAction>& aActionList );
       
   188     
       
   189     /**
       
   190     * Get the state variable list of this action. See interface of 
       
   191     * CUpnpStateVariable to use state variables. 
       
   192     * @since Series60 2.6
       
   193     * @return Gives list of state variables of service.
       
   194     */
       
   195     IMPORT_C RPointerArray<CUpnpStateVariable> StateVariableList() const;
       
   196     
       
   197     IMPORT_C void AddStateVariableL( CUpnpStateVariable* aStateVariable );
       
   198     /**
       
   199     * Creates and returns a new action. This function is proposed to be
       
   200     * used by control points (derived from CUpnpControlPoint).
       
   201     * The target IP address and other details are already set in the 
       
   202     * CUpnpAction structure, and after setting the parameters it can be 
       
   203     * sent using CUpnpServiceImplementation or CUpnpControlPoint interface.
       
   204     * @since Series60 2.6
       
   205     * @param aActionName Name of the action.
       
   206     * @return action object
       
   207     */
       
   208     IMPORT_C CUpnpAction* CreateActionLC( const TDesC8& aActionName );
       
   209 
       
   210    
       
   211         
       
   212 public: // From MUpnpDispatcherCustomer
       
   213 
       
   214     
       
   215     void SetArgumentTypes();
       
   216     
       
   217     TBool IsComplete();
       
   218     
       
   219 protected:
       
   220 
       
   221     /**
       
   222     * C++ default constructor.
       
   223     * @param aDevice Parent device.
       
   224     */
       
   225     IMPORT_C CUpnpService( CUpnpDevice& aDevice );
       
   226     
       
   227     /**
       
   228     * By default Symbian 2nd phase constructor is private.
       
   229     * @param aDesciption Content of the service description.
       
   230     * @param aServiceType Type of the service.
       
   231     */
       
   232     IMPORT_C void ConstructL( const TDesC8& aDescription, 
       
   233                   const TDesC8& aServiceType );  
       
   234 
       
   235 public:
       
   236     static CUpnpService* NewL(CUpnpDevice* aParent);
       
   237       
       
   238     void AddActionL( CUpnpAction& aAction );
       
   239 
       
   240     void Added();
       
   241     
       
   242 protected: // Data
       
   243       
       
   244     // State variable list, owned
       
   245     RPointerArray<CUpnpStateVariable>           iStateVariables;
       
   246 
       
   247     // Action variable list, owned
       
   248     RPointerArray<CUpnpAction>                  iActions;
       
   249 
       
   250     // Not owned; cannot be NULL
       
   251     CUpnpDevice&                                iParentDevice;
       
   252 
       
   253     
       
   254     // Service type, owned
       
   255     HBufC8*                                     iType;
       
   256 
       
   257     // Used to identify messages, owned
       
   258     HBufC8*                                     iPath;
       
   259     // subscription url
       
   260     HBufC8*                                     iSubscriptionUrl;
       
   261     // control url
       
   262     HBufC8*                                     iControlUrl;
       
   263     // adding flag    
       
   264     TBool                                       iIsAdded;
       
   265     // complete flag    
       
   266     TBool                                       iComplete;
       
   267     // url    
       
   268     HBufC8*                                 	iUrl;
       
   269     };
       
   270     
       
   271 
       
   272 #endif  // C_CUPNPSERVICE_H
       
   273 
       
   274 // End of File