commsconfig/cscsipvoipcleanupplugin/src/cscsvcpluginrcsehandler.cpp
changeset 0 a4daefaec16c
child 15 43658d24f35d
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 <e32base.h>
       
    20 #include <crcseprofileregistry.h>
       
    21 
       
    22 #include "cscsvcpluginlogger.h"
       
    23 #include "cscsvcpluginrcsehandler.h"
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CCSCSvcPluginRcseHandler::CCSCSvcPluginRcseHandler()
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CCSCSvcPluginRcseHandler::ConstructL()
       
    41     {    
       
    42     CSCSVCPLUGINDEBUG("CCSCSvcPluginRcseHandler::ConstructL - begin");
       
    43     
       
    44     iRcseProfileRegistry = CRCSEProfileRegistry::NewL();
       
    45     
       
    46     CSCSVCPLUGINDEBUG("CCSCSvcPluginRcseHandler::ConstructL - end");
       
    47     }
       
    48 
       
    49     
       
    50 // ---------------------------------------------------------------------------
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CCSCSvcPluginRcseHandler* CCSCSvcPluginRcseHandler::NewL()
       
    54     {
       
    55     CCSCSvcPluginRcseHandler* self = 
       
    56         new ( ELeave ) CCSCSvcPluginRcseHandler();
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CCSCSvcPluginRcseHandler::~CCSCSvcPluginRcseHandler()
       
    68     {
       
    69     CSCSVCPLUGINDEBUG(
       
    70         "CCSCSvcPluginRcseHandler::~CCSCSvcPluginRcseHandler - begin");
       
    71     
       
    72     delete iRcseProfileRegistry; 
       
    73     
       
    74     CSCSVCPLUGINDEBUG(
       
    75         "CCSCSvcPluginRcseHandler::~CCSCSvcPluginRcseHandler - end");
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Returns VoIP profile id for corresponding EasyVoIP plugin.
       
    81 // Also returns SIP profile reference ids if any 
       
    82 // was found from VoIP profile entry.
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 void CCSCSvcPluginRcseHandler::GetProfileIdsL( 
       
    86     TUint32 aServiceId, 
       
    87     TUint32& aProfileId,
       
    88     RArray<TUint32>& aSipProfileIds )
       
    89     {
       
    90     CSCSVCPLUGINDEBUG( "CCSCSvcPluginRcseHandler::GetProfileIdsL - begin");
       
    91     
       
    92     RPointerArray<CRCSEProfileEntry> entries;
       
    93     TCleanupItem clItem( ResetAndDestroy, &entries );
       
    94     CleanupStack::PushL( clItem );
       
    95 
       
    96     // Get VoIP setting id
       
    97     iRcseProfileRegistry->FindByServiceIdL( aServiceId, entries );
       
    98                             
       
    99     if ( entries.Count() )
       
   100         {
       
   101         aProfileId = entries[ 0 ]->iId;
       
   102                             
       
   103 	    // Check profile for SIP references and append ids to array.
       
   104 	    for ( TInt j = 0; j < entries[ 0 ]->iIds.Count(); j++ )
       
   105 	        {
       
   106 	        TUint32 id = entries[ 0 ]->iIds[ j ].iProfileId;
       
   107 	        User::LeaveIfError( aSipProfileIds.Append( id ) );
       
   108 	        }
       
   109         }
       
   110     else
       
   111         {
       
   112         User::Leave( KErrNotFound );
       
   113         }
       
   114         
       
   115     CleanupStack::PopAndDestroy(); // clItem    
       
   116     
       
   117     CSCSVCPLUGINDEBUG( "CCSCSvcPluginRcseHandler::GetProfileIdsL - end");
       
   118     }
       
   119 
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // Destroys VoIP profile from RCSE based on VoIP profile id.
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CCSCSvcPluginRcseHandler::RemoveProfileL(
       
   126     TUint32 aProfileId )
       
   127     {    
       
   128     CSCSVCPLUGINDEBUG( "CCSCSvcPluginRcseHandler::RemoveProfileL - begin");
       
   129     
       
   130     // Destroy VoIP profile from RCSE.
       
   131     CRCSEProfileEntry* entry = CRCSEProfileEntry::NewLC();
       
   132     iRcseProfileRegistry->FindL( aProfileId, *entry );
       
   133     iRcseProfileRegistry->DeleteL( aProfileId );
       
   134     CleanupStack::PopAndDestroy( entry );
       
   135     
       
   136     CSCSVCPLUGINDEBUG( "CCSCSvcPluginRcseHandler::RemoveProfileL - end");
       
   137     }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // For deleting RPointerArray in case of leave
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 void CCSCSvcPluginRcseHandler::ResetAndDestroy( TAny* aPointerArray )
       
   145     {
       
   146     CSCSVCPLUGINDEBUG( "CCSCSvcPluginRcseHandler::ResetAndDestroy - begin");
       
   147     
       
   148     if ( aPointerArray )
       
   149         {
       
   150         RPointerArray<CRCSEProfileEntry>* array =
       
   151             static_cast<RPointerArray<CRCSEProfileEntry>*>( aPointerArray );
       
   152         array->ResetAndDestroy();
       
   153         array->Close();
       
   154         }
       
   155     
       
   156     CSCSVCPLUGINDEBUG( "CCSCSvcPluginRcseHandler::ResetAndDestroy - end");
       
   157     }
       
   158