commsconfig/cscengine/src/cscengdestinationshandler.cpp
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     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:  For handling interactions betweed UI and CMM.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <cmpluginwlandef.h>
       
    19 #include <cmdestinationext.h>
       
    20 #include <cmconnectionmethodext.h>
       
    21 
       
    22 #include "cscenglogger.h"
       
    23 #include "cscengdestinationshandler.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CCSCEngDestinationsHandler::CCSCEngDestinationsHandler()
       
    31     {    
       
    32     }
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void CCSCEngDestinationsHandler::ConstructL()
       
    39     {
       
    40     CSCENGDEBUG( "CCSCEngDestinationsHandler::ConstructL - begin" ); 
       
    41     
       
    42     // Create connection to Connection Method Manager.
       
    43     iCmManager.OpenL();
       
    44     
       
    45     CSCENGDEBUG( "CCSCEngDestinationsHandler::ConstructL - end" ); 
       
    46     }   
       
    47     
       
    48     
       
    49 // ---------------------------------------------------------------------------
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CCSCEngDestinationsHandler* CCSCEngDestinationsHandler::NewL()
       
    53     {    
       
    54     CCSCEngDestinationsHandler* self = 
       
    55         new ( ELeave ) CCSCEngDestinationsHandler();
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CCSCEngDestinationsHandler::~CCSCEngDestinationsHandler()
       
    67     {
       
    68     CSCENGDEBUG( 
       
    69         "CCSCEngDestinationsHandler::~CCSCEngDestinationsHandler - begin" ); 
       
    70     
       
    71     iCmManager.Close();
       
    72     
       
    73     CSCENGDEBUG( 
       
    74         "CCSCEngDestinationsHandler::~CCSCEngDestinationsHandler - end" ); 
       
    75     }
       
    76     
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CCSCEngDestinationsHandler::AvailableSnapIdsL
       
    80 // Returns available destination ids in the device.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C void CCSCEngDestinationsHandler::AvailableSnapIdsL( 
       
    84     RArray<TUint32>& aSnapIds )
       
    85     {
       
    86     iCmManager.AllDestinationsL( aSnapIds );
       
    87     }
       
    88 
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CCSCEngDestinationsHandler::SnapNameL
       
    92 // Returns destination name based on destination id.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C HBufC* CCSCEngDestinationsHandler::SnapNameL( TUint32 aSnapId )
       
    96     {
       
    97     // Get destination name based on destination id from CM Manager. 
       
    98     // Function leaves if destination wasn't found.
       
    99     HBufC* snapName = NULL;
       
   100     RArray<TUint32> snapIds;
       
   101     CleanupClosePushL( snapIds );
       
   102     AvailableSnapIdsL( snapIds );
       
   103     for ( TInt i = 0; i < snapIds.Count() && !snapName; i++ )
       
   104         {
       
   105         if ( aSnapId == snapIds[ i ] )
       
   106             {
       
   107             snapName = iCmManager.DestinationL( aSnapId ).NameLC();
       
   108             CSCENGDEBUG2( 
       
   109                 "CCSCEngDestinationsHandler::SnapNameLC: snapName=%S", 
       
   110                     snapName );
       
   111             CleanupStack::Pop( snapName );
       
   112             }
       
   113         }
       
   114     CleanupStack::PopAndDestroy( &snapIds );
       
   115     
       
   116     if ( !snapName )
       
   117         {
       
   118         User::Leave( KErrNotFound );
       
   119         }
       
   120     
       
   121     return snapName;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CCSCEngDestinationsHandler::IsSnapInUseL
       
   126 // Returns ETrue if snap is in use.
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C TBool CCSCEngDestinationsHandler::IsSnapInUseL( TUint32 aSnapId )
       
   130     {
       
   131     return iCmManager.DestinationL( aSnapId ).IsConnectedL();
       
   132     }