upnp/upnpstack/serviceframework/inc/upnpsubscriberlibraryelement.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:  Declares the CUpnpSubscriberLibraryElement class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CUPNPSUBSCRIBERLIBRARYELEMENT_H
       
    20 #define C_CUPNPSUBSCRIBERLIBRARYELEMENT_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 //#include <e32std.h>
       
    25 #include <in_sock.h>
       
    26 #include "upnptimeoutelement.h"
       
    27 #include "upnperrors.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 
       
    31 class CUpnpGenaMessage;
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 _LIT8( KDefaultTimeout, "300" );
       
    36 const TUint KMaxRenewTimeout = 2100;
       
    37 const TUint KDefaultTimeoutValue = 300;
       
    38 // 2^31-1 // to avoid warning!
       
    39 const TUint32 KMaxSeq = 2146583647; 
       
    40 const TUint32 KMinSeq = 1;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 *  A class which is used to hold subscriber information.
       
    46 *  This class is used by CUpnpSubscriberLibrary to keep a list 
       
    47 *  of service subscribers.
       
    48 *
       
    49 *  @since Series60 2.6
       
    50 */
       
    51 class CUpnpSubscriberLibraryElement : public CUpnpTimeoutElement
       
    52 {
       
    53 public: // Constructors and destructor
       
    54     
       
    55     /** 
       
    56     * Two-phased constructor.
       
    57     * @param aParent
       
    58     * @return The new instance.
       
    59     */
       
    60     static CUpnpSubscriberLibraryElement* NewL( MUpnpTimeoutElementParent& aParent );
       
    61     
       
    62     /** 
       
    63     * Destructor.
       
    64     */
       
    65     virtual ~CUpnpSubscriberLibraryElement();
       
    66         
       
    67 public: // New functions
       
    68 
       
    69     /**
       
    70     * Adds a new subscriber. For a new subscriber, SEQ defaults to zero.
       
    71     * @since Series60 2.6
       
    72     * @param aMessage A valid subscribe message.
       
    73     * @return EHttpOk or error.
       
    74     */
       
    75     TUpnpErrorCode AddSubscriberL(CUpnpGenaMessage* aMessage);
       
    76 
       
    77     /**
       
    78     * Renews subscription.
       
    79     * @since Series60 2.6
       
    80     * @param aMessage A valid subscription renewal message.
       
    81     * @return EHttpOk or error.
       
    82     */
       
    83     TUpnpErrorCode RenewSubscriberL(CUpnpGenaMessage* aMessage);
       
    84         
       
    85 public: // New functions
       
    86 
       
    87     /**
       
    88     * Get SID header
       
    89     * @since Series60 2.6
       
    90     * @return Subscriber ID
       
    91     */
       
    92     TDesC8& Sid();
       
    93 
       
    94     /**
       
    95     * Get callback address
       
    96     * @since Series60 2.6
       
    97     * @return Callback Address
       
    98     */
       
    99     TInetAddr& CallbackAddress();
       
   100         
       
   101     /**
       
   102     * Get callback path
       
   103     * @since Series60 2.6
       
   104     * @return Callback path
       
   105     */
       
   106     TDesC8& CallbackPath();
       
   107 
       
   108     /**
       
   109     * Get SEQ header
       
   110     * @since Series60 2.6
       
   111     * @return Sequence key
       
   112     */
       
   113     TUint32 Seq() const;
       
   114 
       
   115     /**
       
   116     * Get timeout
       
   117     * @since Series60 2.6
       
   118     * @return Subscription expiring timeout
       
   119     */
       
   120     TDesC8& Timeout();
       
   121     
       
   122     /**
       
   123     * Icreases SEQ by 1. If maximum is reached, resets to 1.
       
   124     * @since Series60 2.6
       
   125     */
       
   126     void IncreaseSeq();
       
   127      
       
   128     /**
       
   129     * Set Subscriber ID.
       
   130     * @since Series60 2.6
       
   131     * @param aSid UUID.
       
   132     */
       
   133     void SetSidL( const TDesC8& aSid );
       
   134 
       
   135     /**
       
   136     * Setter for Callback Address.
       
   137     * @since Series60 2.6
       
   138     * @param aIp IPv4
       
   139     * @param aPort Port
       
   140     */
       
   141     void SetCallbackAddress( const TDesC8& aIp, 
       
   142                                       const TDesC8& aPort );
       
   143 
       
   144     /**
       
   145     * Set Callback path.
       
   146     * @since Series60 2.6
       
   147     * @param aCallbackPath Callback path
       
   148     */
       
   149     void SetCallbackPathL( const TDesC8& aCallbackPath );
       
   150 
       
   151     /**
       
   152     * Set Sequence key.
       
   153     * @since Series60 2.6
       
   154     * @param aSeq
       
   155     */
       
   156     void SetSeq( TUint32 aSeq );
       
   157 
       
   158     /**
       
   159     * Set Subscription expiring timeout.
       
   160     * @since Series60 2.6
       
   161     * @param aTimeout
       
   162     */
       
   163     void SetTimeoutL( const TDesC8& aTimeout );
       
   164     
       
   165     void SetSessId(TInt aSessId);
       
   166     
       
   167     TInt SessId();
       
   168         
       
   169 private: // Constructors
       
   170 
       
   171     /**
       
   172     * C++ default constructor.
       
   173     */
       
   174     CUpnpSubscriberLibraryElement( MUpnpTimeoutElementParent& aParent );
       
   175        
       
   176     /**
       
   177     * By default Symbian 2nd phase constructor is private.
       
   178     */
       
   179     void ConstructL();
       
   180         
       
   181 private: // New functions
       
   182 
       
   183     /**
       
   184     * Sets subscription info.
       
   185     * @since Series60 2.6
       
   186     * @param aSid
       
   187     * @param aCallbackIp
       
   188     * @param aCallbackPort
       
   189     * @param aCallbackPath
       
   190     * @param aTimeout
       
   191     */
       
   192     void AddInfoL( const TDesC8& aSid, 
       
   193                             const TDesC8& aCallbackIp, 
       
   194                             const TDesC8& aCallbackPort, 
       
   195                             const TDesC8& aCallbackPath, 
       
   196                             const TDesC8& aTimeout );
       
   197         
       
   198 private: 
       
   199 
       
   200     // SID buffer, owned
       
   201     HBufC8* iSid;
       
   202 
       
   203     // Callback address, owned
       
   204     TInetAddr iCallbackAddress;
       
   205 
       
   206     // Callbck path, owned
       
   207     HBufC8* iCallbackPath;
       
   208 
       
   209     // SEQ buffer, owned
       
   210     TUint32 iSeq;
       
   211 
       
   212     // Timeout buffer, owned
       
   213     HBufC8* iTimeout;
       
   214     
       
   215     //SessionId
       
   216     TInt iSessId;
       
   217 };
       
   218 
       
   219 #endif //   C_CUPNPSUBSCRIBERLIBRARYELEMENT_H
       
   220 
       
   221 //  End of File