commonuis/CommonUi/src/FindItemVoIPExtension.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2005-2008 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:  Get count of VoIP profiles and
       
    15 *               Handles Preferred Telephony setting events.
       
    16 *
       
    17 */
       
    18 
       
    19 #include "FindItemVoIPExtension.h"
       
    20 #include <featmgr.h>
       
    21 #ifndef RD_VOIP_REL_2_2
       
    22 #include <CRCSEProfileRegistry.h>
       
    23 #include <centralrepository.h>
       
    24 #include <SettingsInternalCRKeys.h>
       
    25 
       
    26 // CONSTANTS
       
    27 // Preferred Telephony value is PS call
       
    28 static const TInt KRCSEInternetCallPreferred = 1;
       
    29 // Dynamic VoIP off
       
    30 static const TInt KVoIPOFF = 0;
       
    31 
       
    32 #else
       
    33 #include <spsettings.h>
       
    34 #include <spsettingsvoiputils.h>
       
    35 #endif // RD_VOIP_REL_2_2
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 //
       
    41 #ifndef RD_VOIP_REL_2_2
       
    42 CFindItemVoIPExtension::CFindItemVoIPExtension():
       
    43     iVoIPSupported( EFalse ),
       
    44     iPreferredTelephonyVoIP(EFalse)
       
    45     {
       
    46     }
       
    47 #else
       
    48 CFindItemVoIPExtension::CFindItemVoIPExtension()
       
    49     {
       
    50     }
       
    51 #endif // RD_VOIP_REL_2_2
       
    52 
       
    53 // Two-phased constructor.
       
    54 //
       
    55 CFindItemVoIPExtension* CFindItemVoIPExtension::NewL()
       
    56     {
       
    57     CFindItemVoIPExtension *self =
       
    58         new ( ELeave ) CFindItemVoIPExtension();
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop();
       
    62     return self;
       
    63     }
       
    64 
       
    65 // ConstructL
       
    66 //
       
    67 void CFindItemVoIPExtension::ConstructL()
       
    68     {
       
    69     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
    70         {
       
    71 #ifndef RD_VOIP_REL_2_2
       
    72         TInt VoIPSupported( KVoIPOFF );
       
    73         TInt value( 0 );
       
    74         iVoIPVariation = CRepository::NewL( KCRUidTelephonySettings );
       
    75         iVoIPVariation->Get( KDynamicVoIP, VoIPSupported );
       
    76         iVoIPVariationNotifier = CCenRepNotifyHandler::NewL( *this, *iVoIPVariation,
       
    77             CCenRepNotifyHandler::EIntKey, KDynamicVoIP );
       
    78         iVoIPVariationNotifier->StartListeningL();
       
    79 
       
    80         iVoIPSupported = KVoIPOFF != VoIPSupported;
       
    81 
       
    82         // Create the session
       
    83         iCenRepSession = CRepository::NewL( KCRUidRichCallSettings );
       
    84         iCenRepSession->Get( KRCSEPreferredTelephony, value );
       
    85         if ( iCenRepSession )
       
    86             {
       
    87             iPreferredTelephonyVoIP = KRCSEInternetCallPreferred == value;
       
    88 
       
    89             // Create the notifer
       
    90             iNotifier = CCenRepNotifyHandler::NewL( *this, *iCenRepSession,
       
    91                 CCenRepNotifyHandler::EIntKey, KRCSEPreferredTelephony );
       
    92 
       
    93             // Start listening
       
    94             iNotifier->StartListeningL();
       
    95             }
       
    96 #else
       
    97         // for handling services related data
       
    98         iSPSettings = CSPSettings::NewL();
       
    99         iSPSettingsVoipUtils = CSPSettingsVoIPUtils::NewL();
       
   100 
       
   101 #endif // RD_VOIP_REL_2_2
       
   102         }
       
   103     }
       
   104 
       
   105 // Destructor
       
   106 //
       
   107 CFindItemVoIPExtension::~CFindItemVoIPExtension()
       
   108     {
       
   109 #ifndef RD_VOIP_REL_2_2
       
   110     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   111         {
       
   112         if( NULL != iVoIPVariationNotifier )
       
   113         	{
       
   114         	iVoIPVariationNotifier->StopListening();
       
   115         	}
       
   116         delete iVoIPVariationNotifier;
       
   117         delete iVoIPVariation;
       
   118 
       
   119         delete iNotifier;
       
   120         delete iCenRepSession;
       
   121         }
       
   122 #else
       
   123     delete iSPSettings;
       
   124     delete iSPSettingsVoipUtils;
       
   125 #endif // RD_VOIP_REL_2_2
       
   126     }
       
   127 
       
   128 #ifndef RD_VOIP_REL_2_2
       
   129 // ----------------------------------------------------
       
   130 //  CFindItemVoIPExtension::HandleNotifyInt
       
   131 //
       
   132 // ----------------------------------------------------
       
   133 //
       
   134 void CFindItemVoIPExtension::HandleNotifyInt(
       
   135     const TUint32 aID,
       
   136     const TInt    aNewValue )
       
   137     {
       
   138     if ( KRCSEPreferredTelephony == aID )
       
   139         {
       
   140         iPreferredTelephonyVoIP =
       
   141             KRCSEInternetCallPreferred == aNewValue;
       
   142         }
       
   143     if ( KDynamicVoIP == aID )
       
   144         {
       
   145         iVoIPSupported = KVoIPOFF != aNewValue;
       
   146         }
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------
       
   150 //  CFindItemVoIPExtension::HandleNotifyError
       
   151 // ----------------------------------------------------
       
   152 //
       
   153 void CFindItemVoIPExtension::HandleNotifyError(
       
   154     const TUint32 /*aID*/,
       
   155     const TInt    /*aError*/,
       
   156   CCenRepNotifyHandler* /*aHandler*/ )
       
   157     {
       
   158     //NO OPERATION
       
   159     }
       
   160 #endif // !RD_VOIP_REL_2_2
       
   161 
       
   162 // ----------------------------------------------------
       
   163 // CFindItemVoIPExtension::VoIPProfilesExistL
       
   164 //
       
   165 // ----------------------------------------------------
       
   166 TBool CFindItemVoIPExtension::VoIPProfilesExistL() const
       
   167     {
       
   168 #ifndef RD_VOIP_REL_2_2
       
   169   TBool isProfiles = EFalse;
       
   170 
       
   171     if ( iVoIPSupported )
       
   172         {
       
   173         RArray<TUint32> profileArray;
       
   174 
       
   175         CRCSEProfileRegistry* rcseProfileRegistry = CRCSEProfileRegistry::NewLC();
       
   176         rcseProfileRegistry->GetAllIdsL( profileArray );
       
   177 
       
   178         if ( profileArray.Count() > 0 )
       
   179             {
       
   180             isProfiles = ETrue;
       
   181             }
       
   182 
       
   183         profileArray.Close();
       
   184 
       
   185         CleanupStack::PopAndDestroy(); // rcseProfile
       
   186         }
       
   187 
       
   188     return isProfiles;
       
   189 #else // RD_VOIP_REL_2_2
       
   190     TBool ret( EFalse );
       
   191 
       
   192     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   193         {
       
   194         ret = iSPSettings->IsFeatureSupported( ESupportVoIPFeature );
       
   195         }
       
   196 
       
   197     return ret;
       
   198 #endif // !RD_VOIP_REL_2_2
       
   199     }
       
   200 
       
   201 // ----------------------------------------------------
       
   202 // CFindItemVoIPExtension::IsPreferredTelephonyVoIP
       
   203 //
       
   204 // ----------------------------------------------------
       
   205 TBool CFindItemVoIPExtension::IsPreferredTelephonyVoIP()
       
   206     {
       
   207 #ifndef RD_VOIP_REL_2_2
       
   208     return iPreferredTelephonyVoIP && iVoIPSupported;
       
   209 #else // RD_VOIP_REL_2_2
       
   210     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   211         {
       
   212         return iSPSettingsVoipUtils->IsPreferredTelephonyVoIP();
       
   213         }
       
   214     else
       
   215         {
       
   216         return EFalse;
       
   217         }
       
   218 #endif // !RD_VOIP_REL_2_2
       
   219     }
       
   220 
       
   221 // ----------------------------------------------------
       
   222 // CFindItemVoIPExtension::IsVoIPSupported
       
   223 //
       
   224 // ----------------------------------------------------
       
   225 TBool CFindItemVoIPExtension::IsVoIPSupported()
       
   226     {
       
   227 #ifndef RD_VOIP_REL_2_2
       
   228     return iVoIPSupported;
       
   229 #else // RD_VOIP_REL_2_2
       
   230     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   231         {
       
   232         return iSPSettings->IsFeatureSupported( ESupportVoIPFeature );
       
   233         }
       
   234     else
       
   235         {
       
   236         return EFalse;
       
   237         }
       
   238 #endif // !RD_VOIP_REL_2_2
       
   239     }
       
   240 //  End of File
       
   241