voipplugins/sipconnectionprovider/inc/scpsipconnection.h
changeset 0 a4daefaec16c
child 10 ed1e38b404e5
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2002-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 *
       
    16 */
       
    17 
       
    18 #ifndef C_SCPSIPCONNECTION_H
       
    19 #define C_SCPSIPCONNECTION_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <rconnmon.h>
       
    23 #include <sipconnectionobserver.h>
       
    24 #include <sipprofileregistryobserver.h>
       
    25 
       
    26 #include "scpdefs.h"
       
    27 
       
    28 class CSIPProfileRegistry;
       
    29 class CSIPProfile;
       
    30 class CSIPManagedProfileRegistry;
       
    31 class MScpSipConnectionObserver;
       
    32 
       
    33 /**
       
    34  *  Register/unregister protocol profiles.
       
    35  *
       
    36  *  @lib sipconnectionprovider.dll
       
    37  *  @since Series 60 3.2
       
    38  */
       
    39 class CScpSipConnection : public CBase,
       
    40                           public MSIPConnectionObserver  
       
    41     {
       
    42 public:
       
    43 
       
    44     enum TConnectionState
       
    45         {
       
    46         EUnknown = 0,
       
    47         ERegistering,
       
    48         ERegistered,
       
    49         EDeregistering,
       
    50         EDeregistered,
       
    51         };
       
    52 
       
    53     enum TRegistrationRequestState
       
    54         {
       
    55         ENoRequest = 0,
       
    56         ERegistrationRequested,
       
    57         EDeregistrationRequested
       
    58         };
       
    59 
       
    60     /**
       
    61      * Two-phased constructor.
       
    62      */
       
    63     static CScpSipConnection* NewL( TInt aProfileId, 
       
    64                                     CSIPProfileRegistry& aProfileRegistry,
       
    65                                     CSIPManagedProfileRegistry& aManagedProfileRegistry,
       
    66                                     CSIP& aSip );
       
    67     /**
       
    68      * Destructor.
       
    69      */
       
    70     virtual ~CScpSipConnection();
       
    71 
       
    72     /**
       
    73      * Return sip profile id of this connection
       
    74      * @return Profile id
       
    75      */  
       
    76     TInt ProfileId() const;
       
    77 
       
    78     /**
       
    79      * Enables the connection
       
    80      */  
       
    81     void EnableL();
       
    82 
       
    83     /**
       
    84      * Disables the connection.
       
    85      * @return Symbian error codes
       
    86      */  
       
    87     TInt Disable();
       
    88 
       
    89     /**
       
    90      * Returns state of deregistration request
       
    91      * @return Registration state
       
    92      */
       
    93     TRegistrationRequestState RegistrationRequestState() const;
       
    94 
       
    95     /**
       
    96      * Get sip connection state
       
    97      * @return State
       
    98      */
       
    99     void GetState( TConnectionState& aState, TInt& aError ) const;
       
   100 
       
   101     /**
       
   102      * Adds observer for the connection
       
   103      * @param aObserver Observer
       
   104      */
       
   105     void AddObserver( MScpSipConnectionObserver& aObserver );
       
   106 
       
   107     /**
       
   108      * Removes observer from this connection
       
   109      * @param aObserver Observer
       
   110      * @return Symbian error codes
       
   111      */
       
   112     TInt RemoveObserver( MScpSipConnectionObserver& aObserver );
       
   113 
       
   114     /**
       
   115      * Gets Protocol Profile's IAP Id.
       
   116      * @return Iap id
       
   117      */                                     
       
   118     TInt GetIap( TUint32& aIapId ) const;
       
   119 
       
   120     /**
       
   121      * Gets Protocol Profile's SNAP Id.
       
   122      * @return Snap id.
       
   123      */                                     
       
   124     TInt GetSnap( TUint32& aSnapId ) const;
       
   125 
       
   126     /**
       
   127      * Gets Protocol Profile's Username..
       
   128      * @param aUsername  Username of profile.
       
   129      * @return KErrNone if succeed.
       
   130      */                                     
       
   131     TInt GetUsername( TDes8& aUsername ) const;
       
   132 
       
   133     /**
       
   134      * Gets Protocol Profile's domain.
       
   135      * @param aDomain  Domain of profile.
       
   136      * @return KErrNone if succeed.
       
   137      */                                     
       
   138     TInt GetDomain( TDes8& aDomain ) const;
       
   139                           
       
   140     /**
       
   141      * Gets Protocol Profile's User name from Contact header
       
   142      * @param aDomain  Domain of profile.
       
   143      * @return KErrNone if succeed.
       
   144      */                                     
       
   145     TInt GetContactHeaderUser( RBuf8& aContactHeaderUser ) const;
       
   146 
       
   147     /**
       
   148      * Get CSIPProfile
       
   149      * @return CSIPProfile
       
   150      */
       
   151     CSIPProfile& SipProfile() const;
       
   152 
       
   153     /**
       
   154      * Set Protocol Profile use this IAP.
       
   155      * @since Series 60 3.2
       
   156      * @param aIapId Iap Id.
       
   157      * @return KErrNone if succeed.
       
   158      */                                     
       
   159     TInt SetIap( TUint32 aIapId );   
       
   160                          
       
   161     /**
       
   162      * Set Protocol Profile use this SNAP.
       
   163      * @param aSnapId  Profile new SNAP Id.
       
   164      * @return KErrNone if succeed.
       
   165      */                                     
       
   166     TInt SetSnap( TUint32 aSnapId );  
       
   167 
       
   168     /**
       
   169      * Returns the type of the iap this connection's profile is using
       
   170      * @return Iap type
       
   171      */
       
   172     TScpIapType GetIapTypeL() const;
       
   173 
       
   174     /**
       
   175      * Profile registry error occurred
       
   176      * @param aProfileId Profile id
       
   177      * @param aError error code
       
   178      */ 
       
   179     void ProfileRegistryErrorOccurred( TInt aError );
       
   180 
       
   181     /**
       
   182      * Updates the sip connection for the used sip profile
       
   183      * @param aProfileId Profile id
       
   184      * @param aEvent Event
       
   185      */ 
       
   186     void ProfileRegistryEventOccurred( MSIPProfileRegistryObserver::TEvent aEvent );
       
   187 
       
   188     /**
       
   189      * Reserve/Free the used connection for a service's use.
       
   190      * For example a VoIP service might reserve the profile for a
       
   191      * duration of a VoIP call
       
   192      * @param aReserved Reserved
       
   193      */
       
   194     void SetReserved( TBool aReserved );
       
   195 
       
   196     /**
       
   197      * Returns information about if a connection is reserved or not
       
   198      * @return ETrue if reserved
       
   199      */
       
   200     TBool Reserved() const;
       
   201 
       
   202     /**
       
   203      * Raises the flag fot iap availability offered. Iap availability
       
   204      * offers may come from SIP during ALR. If the connection is reserved,
       
   205      * the ARL is not allowed and iap available offered is raised.
       
   206      * When the connection is freed the ALR can occur.
       
   207      */
       
   208     void SetIapAvailableOffered( TBool aIapAvailableOffered );
       
   209 
       
   210     /**
       
   211      * Returns the iap available offered flag
       
   212      * @return ETrue if iap available was offered
       
   213      */
       
   214     TBool IapAvailableOffered() const;
       
   215 
       
   216     /**
       
   217      * Sets flag that currenlty the profile is romaing
       
   218      */
       
   219     void SetProfileCurrentlyRoaming();
       
   220     
       
   221     /**
       
   222      * Handle ongoing alr
       
   223      */
       
   224     void HandleMigrationStarted();
       
   225     
       
   226     /**
       
   227      * Handle alr error
       
   228      * @param aError the error that occurred
       
   229      * @param aProfileId identifies the SIP profile related to the error
       
   230      * @param aSnapId the SNAP related to the event
       
   231      * @param aIapId the IAP related to the error
       
   232      */
       
   233     void HandleMigrationError( TInt aError,
       
   234         TUint32 aProfileId, TUint32 aSnapId, TUint32 aIapId ); 
       
   235 
       
   236     /**
       
   237      * Password check.
       
   238      * @return returns always ETrue because information cannot
       
   239      *         be checked from sip
       
   240      */
       
   241     TBool IsPasswordSet() const;
       
   242     
       
   243     /**
       
   244      * Username check.
       
   245      * Checks if digest username is set and username is in aor.
       
   246      * @return ETrue when username exists
       
   247      */
       
   248     TBool IsUsernameSetL() const;
       
   249 
       
   250 #ifdef _DEBUG
       
   251     void GetInfo( TDes& aInfo ) const;
       
   252 #endif
       
   253 
       
   254 private:
       
   255 
       
   256     // From MSIPConnectionObserver
       
   257     void IncomingRequest( CSIPServerTransaction* /*aTransaction*/ ) {};
       
   258 
       
   259     void IncomingRequest( CSIPServerTransaction* /*aTransaction*/,
       
   260                           CSIPDialog& /*aDialog*/ ) {};
       
   261 
       
   262     void IncomingResponse( CSIPClientTransaction& /*aTransaction*/ ) {};
       
   263     
       
   264     void IncomingResponse( CSIPClientTransaction& /*aTransaction*/,
       
   265                             CSIPDialogAssocBase& /*aDialogAssoc*/ ) {};
       
   266 
       
   267     void IncomingResponse( CSIPClientTransaction& /*aTransaction*/,
       
   268                             CSIPInviteDialogAssoc* /*aDialogAssoc*/ ) {};
       
   269 
       
   270     void IncomingResponse( CSIPClientTransaction& /*aTransaction*/,
       
   271                            CSIPRegistrationBinding& /*aRegistration*/ ) {};
       
   272 
       
   273     void ErrorOccured( TInt /*aError*/, CSIPTransactionBase& /*aTransaction*/ ) {};
       
   274 
       
   275     void ErrorOccured( TInt /*aError*/,
       
   276                        CSIPClientTransaction& /*aTransaction*/,
       
   277                        CSIPRegistrationBinding& /*aRegistration*/ ) {};
       
   278 
       
   279     void ErrorOccured( TInt /*aError*/,
       
   280                        CSIPTransactionBase& /*aTransaction*/,
       
   281                        CSIPDialogAssocBase& /*aDialogAssoc*/ ) {};
       
   282 
       
   283     void ErrorOccured( TInt /*aError*/, CSIPRefresh& /*aSIPRefresh*/ ) {};
       
   284 
       
   285 
       
   286     void ErrorOccured( TInt /*aError*/,                    
       
   287                        CSIPRegistrationBinding& /*aRegistration*/ ) {};
       
   288 
       
   289     void ErrorOccured( TInt /*aError*/,            
       
   290                        CSIPDialogAssocBase& /*aDialogAssoc*/) {};
       
   291 
       
   292     void InviteCompleted( CSIPClientTransaction& /*aTransaction*/ ) {};
       
   293 
       
   294     void InviteCanceled( CSIPServerTransaction& /*aTransaction*/ ) {};        
       
   295 
       
   296     void ConnectionStateChanged( CSIPConnection::TState aState );
       
   297 
       
   298     /**
       
   299      * Checks if connection method used by the sip profile is
       
   300      * available
       
   301      * @return ETrue if available
       
   302      */
       
   303     TBool IsNetworkConnectionAvailable() const;
       
   304 
       
   305     /**
       
   306      * Checks if SNAP connection method used by the sip profile is
       
   307      * available
       
   308      * @return ETrue if available
       
   309      */
       
   310     TBool IsSnapConnectionAvailable( TInt aSnapId ) const;
       
   311     
       
   312     /**
       
   313      * Checks if IAP connection method used by sip profile is
       
   314      * available
       
   315      * @return ETrue if available
       
   316      */
       
   317     TBool IsIapConnectionAvailable( TInt aIapId ) const;
       
   318 
       
   319 private:
       
   320 
       
   321     /**
       
   322      * C++ default constructor.
       
   323      */
       
   324     CScpSipConnection( TInt aProfileId, 
       
   325                        CSIPProfileRegistry& aProfileRegistry,
       
   326                        CSIPManagedProfileRegistry& aManagedProfileRegistry,
       
   327                        CSIP& aSip );
       
   328 
       
   329     /**
       
   330      * By default Symbian 2nd phase constructor is private.
       
   331      */
       
   332     void ConstructL();
       
   333     
       
   334     /**
       
   335      * Starts timeout timer
       
   336      * @param aFunction The function to call after the time out
       
   337      */
       
   338     void StartEnableTimeoutTimer( TInt (*aFunction)(TAny* aPtr) );
       
   339 
       
   340     /**
       
   341      * Cancels the disable timer
       
   342      */
       
   343     void CancelEnableTimeoutTimer();
       
   344     
       
   345     /**
       
   346      * Profile register timeout callback
       
   347      * @param aSelf this object
       
   348      */
       
   349     static TInt EnableTimeout( TAny* aSelf );
       
   350     
       
   351     /**
       
   352      * Handles sip profile register timeout
       
   353      */
       
   354     void HandleEnableTimeout();
       
   355     
       
   356     /**
       
   357      * Changes SIP profile from "Always on" to "When needed" if
       
   358      * the profile was originally set to "Always on"
       
   359      */
       
   360     void DisableAlwaysOnModeL();
       
   361     
       
   362     /**
       
   363      * Checks if Sip profile type is IMS
       
   364      */
       
   365     TBool SipProfileIMS() const;
       
   366     
       
   367 private:
       
   368 
       
   369     /**
       
   370      * Sip profile id
       
   371      */
       
   372     TInt iProfileId;
       
   373 
       
   374     /**
       
   375      * Sip profile registry
       
   376      */
       
   377     CSIPProfileRegistry& iProfileRegistry;
       
   378 
       
   379     /**
       
   380      * Managed sip profile registry
       
   381      */
       
   382     CSIPManagedProfileRegistry& iManagedProfileRegistry;
       
   383   
       
   384     /**
       
   385      * SIP instance
       
   386      */  
       
   387     CSIP& iSip;
       
   388     
       
   389     /**
       
   390      * Sip profile. May change. Own
       
   391      */    
       
   392     CSIPProfile* iSipProfile;
       
   393 
       
   394     /**
       
   395      * Observer
       
   396      */
       
   397     MScpSipConnectionObserver* iObserver;
       
   398 
       
   399     /**
       
   400      * Registration request state
       
   401      */
       
   402     TRegistrationRequestState iRegistrationRequestState;
       
   403 
       
   404     /**
       
   405      * Registration faile flag
       
   406      */
       
   407     TInt iConnectionStateError;
       
   408 
       
   409     /**
       
   410      * Timeout timer. Owned.
       
   411      */
       
   412     CPeriodic* iEnableTimeoutTimer;
       
   413 
       
   414     /**
       
   415      * Connection reserved for services' usage
       
   416      */
       
   417     TBool iReserved;
       
   418 
       
   419     /**
       
   420      * Iap available offered
       
   421      */
       
   422     TBool iIapAvailableOffered;
       
   423 
       
   424     /**
       
   425      * Profile is currently roaming
       
   426      */
       
   427     TBool iProfileCurrentlyRoaming;
       
   428 
       
   429     /**
       
   430      * Connection monitor
       
   431      */
       
   432     RConnectionMonitor iConnectionMonitor;
       
   433 
       
   434     /**
       
   435      * SIP connection
       
   436      * Own.
       
   437      */
       
   438     CSIPConnection* iSipConnection;
       
   439 
       
   440 // This need to be cleaned to separate macro/header
       
   441 #ifdef _DEBUG
       
   442     friend class T_CScpSipConnection; 
       
   443     friend class T_CScpProfileHandler;
       
   444     friend class T_CScpServiceManager;
       
   445     friend class T_CScpVmbxHandler;
       
   446     friend class T_CScpVoipHandler;
       
   447 #endif
       
   448     };
       
   449 
       
   450 #endif      // C_SCPSIPCONNECTION_H   
       
   451             
       
   452 // End of File