realtimenetprots/sipfw/ProfileAgent/IMS_Agent/Inc/CSIPRegEventSubscriber.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:
       
    15 * Name        : CSIPRegEventSubscriber.h
       
    16 * Part of     : SIP Profile Agent
       
    17 * Interface   : 
       
    18 * Version     : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @internalComponent
       
    27 */
       
    28 
       
    29 
       
    30 #ifndef	CSIPREGEVENTSUBSCRIBER_H
       
    31 #define CSIPREGEVENTSUBSCRIBER_H
       
    32 
       
    33 //  INCLUDES
       
    34 #include <e32base.h>
       
    35 #include <uri8.h>
       
    36 #include <stringpool.h>
       
    37 #include "sipregeventcontext.h"
       
    38 #include "TSIPRegEventSubscriptionStateBase.h"
       
    39 #include "sipregeventsubscriberobserver.h"
       
    40 #include "sipconnection.h"
       
    41 #include "sipdialog.h"
       
    42 #include "sipsubscribedialogassoc.h"
       
    43 #include "sipclienttransaction.h"
       
    44 #include "sipservertransaction.h"
       
    45 #include "sipmessageelements.h"
       
    46 #include "siprequestelements.h"
       
    47 #include "sipheaderbase.h"
       
    48 #include "sipreginfoelement.h"
       
    49 #include "_sipcodecdefs.h"
       
    50 #include <sipprofileagentextensionparams.h>
       
    51 
       
    52 // FORWARD DECLARATIONS
       
    53 class CSIPSubscriptionStateHeader;
       
    54 class CSIPNotifyXmlBodyParser;
       
    55 
       
    56 // CLASS DECLARATION
       
    57 //
       
    58 class CSIPRegEventSubscriber : public CBase, public MSIPRegEventContext
       
    59 	{
       
    60     public: // Constructors and destructor
       
    61 	
       
    62 	    static CSIPRegEventSubscriber* NewL(CSIPNotifyXmlBodyParser& aXmlParser,
       
    63 	                                        CSIPConnection& aConnection,
       
    64 	                                        MSIPRegistrationContext& aContext,
       
    65 	                                        CUri8& aUserIdentity,
       
    66 	                                        MSIPRegEventSubscriberObserver& aObserver,
       
    67 	                                        CSipProfileAgentConfigExtension& aConfigExtension);
       
    68 	                                    
       
    69 	    static CSIPRegEventSubscriber* NewLC(CSIPNotifyXmlBodyParser& aXmlParser,
       
    70 	                                         CSIPConnection& aConnection,
       
    71 	                                         MSIPRegistrationContext& aContext,
       
    72 	                                         CUri8& aUserIdentity,
       
    73 	                                         MSIPRegEventSubscriberObserver& aObserver,
       
    74 	                                         CSipProfileAgentConfigExtension& aConfigExtension);
       
    75 	    ~CSIPRegEventSubscriber();		
       
    76 	
       
    77 	public: // New functions
       
    78 	
       
    79 	    void SubscribeL();
       
    80 	    
       
    81 	    void ReSubscribeL();
       
    82 	    
       
    83 	    void RefreshL();	
       
    84 
       
    85         TBool HasTransaction(const CSIPTransactionBase& aTransaction) const;
       
    86 
       
    87         TBool HasRefresh(const CSIPRefresh& aRefresh) const;
       
    88 
       
    89 	    TBool HasDialog(const CSIPDialog& aDialog) const;
       
    90 	
       
    91 	    void RequestReceivedL(CSIPServerTransaction* aTransaction,
       
    92 					          CSIPDialog& aDialog);
       
    93 					           
       
    94         void ResponseReceivedL(CSIPClientTransaction& aTransaction);
       
    95 					            
       
    96         void ErrorOccured(TInt aError,
       
    97 				          CSIPTransactionBase& aTransaction);
       
    98 				          
       
    99         void ErrorOccured(TInt aError,
       
   100 				          CSIPDialog& aDialog);
       
   101 				          			          
       
   102 
       
   103 	public: // From MSIPRegEventContext
       
   104 	
       
   105         void DoSubscribeL();
       
   106         
       
   107         void DoRefreshL();
       
   108         
       
   109         void ReSubscribeAfterL(TUint aRetryAfter);
       
   110         
       
   111         void SubscriptionFailedL();
       
   112         
       
   113         void RegEventNotSupportedByNetworkL();
       
   114         
       
   115         void ReRegister();
       
   116         
       
   117         void ChangeState(TState aNewState);
       
   118 
       
   119 
       
   120     private: // New functions
       
   121     
       
   122 	    CSIPResponseElements* 
       
   123 	        HandleReceivedRequestLC(const CSIPRequestElements& aRequest);
       
   124 					           
       
   125         void HandleReceivedResponseL(const CSIPResponseElements& aResponse);
       
   126         
       
   127         TUint RetryAfterValue(const CSIPResponseElements& aResponse) const; 
       
   128     
       
   129         void ParseXmlL(const CSIPRequestElements& aRequest);
       
   130     
       
   131         void HandleSubscriptionStateL(const CSIPRequestElements& aRequest,
       
   132                                       TBool& aTerminated,
       
   133                                       TInt& aRetryAfter);
       
   134         
       
   135         void HandleTerminatedState(CSIPSubscriptionStateHeader& aState,
       
   136                                    TInt& aRetryAfter);
       
   137         
       
   138         CSIPSubscribeDialogAssoc* CreateSubscribeAssocL();
       
   139         
       
   140         CSIPMessageElements* CreateMessageElementsLC(TUint aExpiresValue);
       
   141     
       
   142         TBool MethodOK(const CSIPRequestElements& aRequest);
       
   143         
       
   144         TBool ContentTypeOK(const CSIPRequestElements& aRequest);
       
   145         
       
   146         TBool SubscriptionStateOK(const CSIPRequestElements& aRequest);
       
   147         
       
   148         TBool EventOK(const CSIPRequestElements& aRequest);
       
   149         
       
   150         CSIPHeaderBase* FindHeader(const CSIPMessageElements& aMessage,
       
   151                                    RStringF aHeaderName) const;
       
   152                                    
       
   153         inline TSIPRegEventSubscriptionStateBase& CurrentState();
       
   154 
       
   155     private: // Second phase constructors
       
   156 
       
   157 	    void ConstructL();
       
   158 	                    
       
   159 	    void InitializeStatesL();
       
   160 	
       
   161 	    CSIPRegEventSubscriber(CSIPNotifyXmlBodyParser& aXmlParser,
       
   162 	                           CSIPConnection& aConnection,
       
   163 	                           MSIPRegistrationContext& aContext,
       
   164 	                           CUri8& aUserIdentity,
       
   165 	                           MSIPRegEventSubscriberObserver& aObserver,
       
   166 	                           CSipProfileAgentConfigExtension& aConfigExtension);
       
   167 
       
   168     private: // Data
       
   169 	
       
   170 	    CArrayVarFlat<TSIPRegEventSubscriptionStateBase> iStates;
       
   171 	    MSIPRegEventContext::TState iCurrentState;
       
   172 	    CSIPNotifyXmlBodyParser& iXmlParser;
       
   173 	    CSIPConnection& iConnection;
       
   174 	    MSIPRegistrationContext& iRegistrationContext;
       
   175 	    CUri8& iUserIdentity;
       
   176 	    MSIPRegEventSubscriberObserver& iObserver;
       
   177 	    CSIPSubscribeDialogAssoc* iSubscribeAssoc;
       
   178 	    CSIPClientTransaction* iClientTransaction;
       
   179 	    RStringF iReasonProbation;
       
   180 	    RStringF iReasonRejected;
       
   181 	    RStringF iReasonGiveup;
       
   182 	    RStringF iReasonNoresource;
       
   183 	    CSIPRegInfoElement* iCurrentRegInfoElement;
       
   184 	    CSipProfileAgentConfigExtension& iConfigExtension;
       
   185 	    
       
   186 	private: // Unit test
       
   187 	
       
   188 	    UNIT_TEST(CSIPRegEventSubscriberTest)
       
   189 	    UNIT_TEST(CSIPRegEventHandlerTest)
       
   190 	    UNIT_TEST(CSIPIMSProfileContextTest)
       
   191 	};
       
   192 
       
   193 #endif // CSIPREGEVENTSUBSCRIBER_H