commsconfig/cscsipvoipcleanupplugin/src/cscsvcpluginsiphandler.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <uriutils.h>
       
    20 #include <sipmanagedprofile.h>
       
    21 #include <sipmanagedprofileregistry.h>
       
    22 
       
    23 #include "cscsvcpluginlogger.h"
       
    24 #include "cscsvcpluginsiphandler.h"
       
    25 
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CCSCSvcPluginSipHandler::CCSCSvcPluginSipHandler()
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CCSCSvcPluginSipHandler::ConstructL()
       
    41     {
       
    42     CSCSVCPLUGINDEBUG("CCSCSvcPluginSipHandler::ConstructL - begin");
       
    43     
       
    44     iSipProfileRegistry = CSIPManagedProfileRegistry::NewL( *this );
       
    45     
       
    46     CSCSVCPLUGINDEBUG("CCSCSvcPluginSipHandler::ConstructL - end");
       
    47     }
       
    48 
       
    49     
       
    50 // ---------------------------------------------------------------------------
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CCSCSvcPluginSipHandler* CCSCSvcPluginSipHandler::NewL()
       
    54     {
       
    55     CCSCSvcPluginSipHandler* self = 
       
    56         new ( ELeave ) CCSCSvcPluginSipHandler();
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CCSCSvcPluginSipHandler::~CCSCSvcPluginSipHandler()
       
    68     {
       
    69     CSCSVCPLUGINDEBUG(
       
    70         "CCSCSvcPluginSipHandler::~CCSCSvcPluginSipHandler - begin");
       
    71     
       
    72     delete iSipProfileRegistry;
       
    73     
       
    74     CSCSVCPLUGINDEBUG(
       
    75         "CCSCSvcPluginSipHandler::~CCSCSvcPluginSipHandler - end");
       
    76     }
       
    77 
       
    78     
       
    79 // ---------------------------------------------------------------------------
       
    80 // Destroys SIP profile from SIP Stack based on SIP profile id.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CCSCSvcPluginSipHandler::RemoveProfileL(
       
    84     TUint32 aProfileId )
       
    85     {    
       
    86     CSCSVCPLUGINDEBUG( "CCSCSvcPluginSipHandler::RemoveProfileL - begin");
       
    87     
       
    88     // Destroy VoIP profile from RCSE.
       
    89     CSIPManagedProfile* profile = 
       
    90         static_cast<CSIPManagedProfile*> 
       
    91             ( iSipProfileRegistry->ProfileL( aProfileId ) );
       
    92             
       
    93     CleanupStack::PushL( profile );
       
    94     if ( !iSipProfileRegistry->IsInUseL( *profile ) )
       
    95         {
       
    96         iSipProfileRegistry->DestroyL( *profile );
       
    97         }
       
    98     CleanupStack::PopAndDestroy( profile );
       
    99     
       
   100     CSCSVCPLUGINDEBUG( "CCSCSvcPluginSipHandler::RemoveProfileL - end");
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // SIP profile information event.
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CCSCSvcPluginSipHandler::ProfileRegistryEventOccurred( 
       
   109     TUint32 /*aSIPProfileId*/, 
       
   110     TEvent /*aEvent*/ )
       
   111     {
       
   112     }
       
   113 
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // An asynchronous error has occurred related to SIP profile.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CCSCSvcPluginSipHandler::ProfileRegistryErrorOccurred(
       
   120     TUint32 /*aSIPProfileId*/,
       
   121     TInt /*aError*/ )
       
   122     {
       
   123     }
       
   124     
       
   125 void CCSCSvcPluginSipHandler::SetRegistrationModeL( TUint32 aId, TBool aRegMode )
       
   126 	{
       
   127     CSIPManagedProfile* profile = static_cast<CSIPManagedProfile*> 
       
   128             ( iSipProfileRegistry->ProfileL( aId ) );
       
   129             
       
   130     CleanupStack::PushL( profile );
       
   131     User::LeaveIfError( profile->SetParameter( KSIPAutoRegistration, aRegMode ) );
       
   132     // Save profile back to the persistent storage.
       
   133     iSipProfileRegistry->SaveL( *profile );
       
   134     CleanupStack::PopAndDestroy( profile );
       
   135 	
       
   136 	}
       
   137 
       
   138 void CCSCSvcPluginSipHandler::GetApIdL( TUint32 aId,  TUint32& aApId )
       
   139 	{
       
   140     CSIPProfile* profile = iSipProfileRegistry->ProfileL( aId );
       
   141     CleanupStack::PushL( profile );
       
   142     User::LeaveIfError( profile->GetParameter( KSIPAccessPointId, aApId ) );
       
   143     CleanupStack::PopAndDestroy( profile );
       
   144 	}
       
   145 
       
   146 void CCSCSvcPluginSipHandler::GetUserAorL( TUint32 aId,  TDes8& aUserAor )
       
   147 	{
       
   148     CSIPProfile* profile = iSipProfileRegistry->ProfileL( aId );
       
   149     CleanupStack::PushL( profile );
       
   150     const TDesC8* aor( NULL );
       
   151     User::LeaveIfError( profile->GetParameter( KSIPUserAor, aor ) );
       
   152     if ( aor )
       
   153         {
       
   154         if( aor->Length() <= aUserAor.MaxLength() )
       
   155             {
       
   156             aUserAor.Copy( *aor );
       
   157             }
       
   158         else
       
   159             {
       
   160             User::Leave( KErrOverflow );
       
   161             }
       
   162         }
       
   163     CleanupStack::PopAndDestroy( profile );
       
   164 	}
       
   165 
       
   166