cellular/telephonysettings/src/PsetCSP.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 *      Customer Service Profile wrapper layer for SsSettings. 
       
    16 *      PsetCustomerServiceProfile is a class that access CSP through
       
    17 *      SSsettings. It is in Phone Settings to provide easier access 
       
    18 *      to CSP values. Whole class should only be used if CSP is supported.                                                         
       
    19 *
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 //INCLUDE FILES
       
    25 #include "PsetCSP.h"
       
    26 #include <etelmm.h>
       
    27 #include "PhoneSettingsLogger.h"
       
    28 
       
    29 //  MEMBER FUNCTIONS
       
    30 // ---------------------------------------------------------------------------
       
    31 // 
       
    32 // Symbian OS 1st phase constructor.
       
    33 // 
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C CPsetCustomerServiceProfile* CPsetCustomerServiceProfile::NewL()
       
    37     {
       
    38     CPsetCustomerServiceProfile* self = new ( ELeave ) CPsetCustomerServiceProfile();
       
    39     return self;
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // 
       
    44 // Destructor
       
    45 // 
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CPsetCustomerServiceProfile::~CPsetCustomerServiceProfile()
       
    49     {
       
    50     //If GS has failed to create CSP due to low memory, check it.
       
    51     if ( iCsp )
       
    52         {
       
    53         iCsp->Close();
       
    54         }
       
    55     delete iCsp;
       
    56     iCsp = NULL;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // 
       
    61 // Checks if Call Waiting is to be supported.
       
    62 // 
       
    63 // ---------------------------------------------------------------------------
       
    64 // 
       
    65 EXPORT_C TInt CPsetCustomerServiceProfile::IsCWSupported( TBool& aSupport )
       
    66     {
       
    67     /*****************************************************
       
    68     *    Series 60 Customer / ETel
       
    69     *    Series 60  ETel API
       
    70     *****************************************************/
       
    71     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::IsCWSupported");
       
    72     RMobilePhone::TCspCallCompletion params;    
       
    73     TInt retVal = iCsp->CspCallCompletion( params );
       
    74     aSupport = EFalse;
       
    75 
       
    76     //if bit7 is 1, call waiting is not available through CSP
       
    77     if ( retVal == KErrNone )
       
    78         {
       
    79         aSupport = CheckIfCWSupported( params );
       
    80         }
       
    81 
       
    82     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::IsCWSupported: aSupport: %d", aSupport);
       
    83     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::IsCWSupported");
       
    84     return retVal;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // 
       
    89 // Checks if Call Barring is to be supported.
       
    90 // 
       
    91 // ---------------------------------------------------------------------------
       
    92 // 
       
    93 EXPORT_C TInt CPsetCustomerServiceProfile::IsCBSupported( TBool& aSupport )
       
    94     {
       
    95     /*****************************************************
       
    96     *    Series 60 Customer / ETel
       
    97     *    Series 60  ETel API
       
    98     *****************************************************/
       
    99     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::IsCBSupported");
       
   100     RMobilePhone::TCspCallRestriction params;
       
   101     TInt retVal = iCsp->CspCallRestriction( params );    
       
   102     aSupport = EFalse;
       
   103 
       
   104     //if params more than 1, barring is available through CSP
       
   105     if ( retVal == KErrNone )
       
   106         {
       
   107         aSupport = CheckIfCBSupported( params );
       
   108         }
       
   109 
       
   110     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::IsCBSupported: aSupport: %d", aSupport);
       
   111     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::IsCBSupported");
       
   112     return retVal;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // 
       
   117 // Checks if Call Forwarding is to be supported.
       
   118 // 
       
   119 // ---------------------------------------------------------------------------
       
   120 // 
       
   121 EXPORT_C TInt CPsetCustomerServiceProfile::IsCFSupported( TBool& aSupport )
       
   122     {
       
   123     /*****************************************************
       
   124     *    Series 60 Customer / ETel
       
   125     *    Series 60  ETel API
       
   126     *****************************************************/
       
   127     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::IsCFSupported");
       
   128     RMobilePhone::TCspCallOffering params;
       
   129     TInt retVal = iCsp->CspCallOffering( params );
       
   130     aSupport = EFalse;
       
   131 
       
   132     //if all of first five bits are 1, divert is available through CSP
       
   133     if ( retVal == KErrNone )
       
   134         {
       
   135         aSupport = CheckIfCFSupported( params );
       
   136         }
       
   137 
       
   138     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::IsCFSupported: aSupport: %d", aSupport);
       
   139     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::IsCFSupported");
       
   140     return retVal;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // 
       
   145 // Checks if Alternate Line is to be supported.
       
   146 // 
       
   147 // ---------------------------------------------------------------------------
       
   148 // 
       
   149 EXPORT_C TInt CPsetCustomerServiceProfile::IsALSSupported( TBool& aSupport )
       
   150     {
       
   151     /*****************************************************
       
   152     *    Series 60 Customer / ETel
       
   153     *    Series 60  ETel API
       
   154     *****************************************************/
       
   155     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::IsALSSupported");
       
   156     RMobilePhone::TCspCPHSTeleservices params;
       
   157     TInt retVal = iCsp->CspCPHSTeleservices( params );
       
   158     aSupport = EFalse;
       
   159 
       
   160     if ( retVal == KErrNone )
       
   161         {
       
   162         aSupport = CheckIfAlsSupported( params );
       
   163         }
       
   164 
       
   165     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::IsALSSupported: aSupport: %d", aSupport);
       
   166     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::IsALSSupported");
       
   167     return retVal;
       
   168     }
       
   169 
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // 
       
   173 // Open CSP from SIM.
       
   174 // 
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C TInt CPsetCustomerServiceProfile::OpenCSProfileL()
       
   178     {
       
   179     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::OpenCSProfileL");
       
   180     if ( !iCsp )
       
   181         {
       
   182         iCsp = new (ELeave) RCustomerServiceProfileCache;    
       
   183         }
       
   184     TInt error = iCsp->Open();
       
   185 
       
   186     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::OpenCSProfileL: error: %d", error);
       
   187     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::OpenCSProfileL");
       
   188     return error;
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // 
       
   193 // Checks if Manual Network Selection is to be supported.
       
   194 // 
       
   195 // ---------------------------------------------------------------------------
       
   196 // 
       
   197 EXPORT_C TInt CPsetCustomerServiceProfile::IsNetworkSelectionSupported( 
       
   198     TBool& aSupport )
       
   199     {
       
   200     /*****************************************************
       
   201     *    Series 60 Customer / ETel
       
   202     *    Series 60  ETel API
       
   203     *****************************************************/
       
   204     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::IsNetworkSelectionSupported");
       
   205     RMobilePhone::TCspValueAdded params;
       
   206     TInt retVal = iCsp->CspCPHSValueAddedServices( params );
       
   207     aSupport = EFalse;
       
   208 
       
   209     if ( retVal == KErrNone )
       
   210         {
       
   211         aSupport = CheckIfNetworkSelectionSupported( params );
       
   212         }
       
   213 
       
   214     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::IsNetworkSelectionSupported: aSupport: %d", aSupport);
       
   215     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::IsNetworkSelectionSupported");
       
   216     return  retVal;
       
   217     }
       
   218 
       
   219 
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // CPsetCustomerServiceProfile::CheckIfCWSupported
       
   223 // 
       
   224 // 
       
   225 // ---------------------------------------------------------------------------
       
   226 // 
       
   227 TBool CPsetCustomerServiceProfile::CheckIfCWSupported(
       
   228     const RMobilePhone::TCspCallCompletion aContainer ) const
       
   229     {
       
   230     return IsSupported( aContainer, RMobilePhone::KCspCW );
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CPsetCustomerServiceProfile::CheckIfCBSupported
       
   235 // 
       
   236 // 
       
   237 // ---------------------------------------------------------------------------
       
   238 // 
       
   239 TBool CPsetCustomerServiceProfile::CheckIfCBSupported(
       
   240     const RMobilePhone::TCspCallRestriction aContainer ) const
       
   241     {
       
   242     return ( 
       
   243         IsSupported( aContainer, RMobilePhone::KCspBICRoam )||
       
   244         IsSupported( aContainer, RMobilePhone::KCspBAIC ) ||
       
   245         IsSupported( aContainer, RMobilePhone::KCspBOICexHC ) ||
       
   246         IsSupported( aContainer, RMobilePhone::KCspBOIC ) ||
       
   247         IsSupported( aContainer, RMobilePhone::KCspBOAC ) );
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CPsetCustomerServiceProfile::CheckIfCFSupported
       
   252 // 
       
   253 // 
       
   254 // ---------------------------------------------------------------------------
       
   255 // 
       
   256 TBool CPsetCustomerServiceProfile::CheckIfCFSupported(
       
   257     const RMobilePhone::TCspCallOffering aContainer ) const
       
   258     {
       
   259     return ( 
       
   260         IsSupported( aContainer, RMobilePhone::KCspCFU )   ||
       
   261         IsSupported( aContainer, RMobilePhone::KCspCFB )   ||
       
   262         IsSupported( aContainer, RMobilePhone::KCspCFNRc ) ||
       
   263         IsSupported( aContainer, RMobilePhone::KCspCFNRy ) );
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------------------------
       
   267 // CPsetCustomerServiceProfile::CheckIfAlsSupported
       
   268 // 
       
   269 // 
       
   270 // ---------------------------------------------------------------------------
       
   271 // 
       
   272 TBool CPsetCustomerServiceProfile::CheckIfAlsSupported(
       
   273     const RMobilePhone::TCspCPHSTeleservices aContainer ) const
       
   274     {
       
   275     return IsSupported( aContainer, RMobilePhone::KCspALS );
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // CPsetCustomerServiceProfile::CheckIfNetworkSelectionSupported
       
   280 // 
       
   281 // 
       
   282 // ---------------------------------------------------------------------------
       
   283 // 
       
   284 TBool CPsetCustomerServiceProfile::CheckIfNetworkSelectionSupported(
       
   285     const RMobilePhone::TCspValueAdded aContainer ) const
       
   286     {
       
   287     return IsSupported( aContainer, RMobilePhone::KCspPLMNMode );
       
   288     }
       
   289 
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // CPsetCustomerServiceProfile::IsSupported
       
   293 // 
       
   294 // 
       
   295 // ---------------------------------------------------------------------------
       
   296 // 
       
   297 TBool CPsetCustomerServiceProfile::IsSupported(
       
   298     const TInt aContainer,
       
   299     const TInt aFeature ) const
       
   300     {
       
   301     __PHSLOGSTRING("[PHS]--> CPsetCustomerServiceProfile::IsSupported");
       
   302     TBool supported = EFalse;
       
   303 
       
   304     if ( ( aContainer & aFeature ) != 0 )
       
   305         {
       
   306         supported = ETrue;
       
   307         }
       
   308 
       
   309     __PHSLOGSTRING1("[PHS]   CPsetCustomerServiceProfile::IsSupported: supported: %d", supported);
       
   310     __PHSLOGSTRING("[PHS] <--CPsetCustomerServiceProfile::IsSupported");
       
   311     return supported;
       
   312     }
       
   313 
       
   314 
       
   315 // End of File