cellular/telephonysettings/src/PsetCallDiverting.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     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:  Call diverting class. Sets and gets call diverting status. 
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  Include Files
       
    21 #include <etelmm.h>           
       
    22 #include <e32math.h>
       
    23 #include <e32svr.h>
       
    24 #include <badesca.h>
       
    25 #include <centralrepository.h>
       
    26 #include <settingsinternalcrkeys.h> 
       
    27 
       
    28 #include "psetcalldiverting.h" 
       
    29 #include "psetcontainer.h" 
       
    30 #include "mpsetdivertobs.h" 
       
    31 #include "psettelephony.h" 
       
    32 #include "psetpanic.h" 
       
    33 #include "phonesettingslogger.h" 
       
    34 
       
    35 #include "psetcalldivertingcreator.h" 
       
    36 #include "mcalldiverting.h" 
       
    37 
       
    38 //  MEMBER FUNCTIONS
       
    39 // ---------------------------------------------------------------------------
       
    40 // First phase constructor
       
    41 // ---------------------------------------------------------------------------       
       
    42 EXPORT_C CPsetCallDiverting* CPsetCallDiverting::NewL( MPsetDivertObserver& aObserver,
       
    43                   RMobilePhone& aPhone )
       
    44     {
       
    45     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::NewL");
       
    46     CPsetCallDiverting* self = new ( ELeave ) CPsetCallDiverting( aPhone );
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL( aObserver );
       
    49     CleanupStack::Pop( self );
       
    50     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::NewL");
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Destructor.
       
    56 // ---------------------------------------------------------------------------
       
    57 EXPORT_C CPsetCallDiverting::~CPsetCallDiverting()
       
    58     {
       
    59     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::~CPsetCallDiverting");
       
    60     iReqObserver = NULL;
       
    61 
       
    62     delete iRepository;
       
    63     
       
    64     delete iDivert;
       
    65     iDivert = NULL;
       
    66     __PHSLOGSTRING("[PHS]<-- CPsetCallDiverting::~CPsetCallDiverting");
       
    67     } 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Symbian OS constructor
       
    71 // ---------------------------------------------------------------------------
       
    72 void CPsetCallDiverting::ConstructL( MPsetDivertObserver& aObserver )
       
    73     {
       
    74     __PHSLOGSTRING("[PHS] -->CPsetCallDiverting::ConstructL" );
       
    75     iDivert= CPSetCallDivertingCreator::CreateCallDivertingL( aObserver, iPhone, this );
       
    76     iRepository = CRepository::NewL( KCRUidCallForwarding );
       
    77     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::ConstructL" );
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // C++ constructor
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CPsetCallDiverting::CPsetCallDiverting( RMobilePhone& aPhone ) :
       
    85                     iPhone ( aPhone )
       
    86     {
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Sets diverting. 
       
    91 // ---------------------------------------------------------------------------
       
    92 EXPORT_C void CPsetCallDiverting::SetDivertingL( 
       
    93     const TCallDivertSetting& aDivert, 
       
    94     TBasicServiceGroups aBsc, TBool /*aVmbx*/ )
       
    95     {
       
    96     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetDivertingL");    
       
    97     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetDivertingL: aDivert.iCondition: %d", aDivert.iCondition );
       
    98     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetDivertingL: aDivert.iStatus: %d", aDivert.iStatus );
       
    99     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetDivertingL: aDivert.iServiceGroup: %d", aDivert.iServiceGroup );
       
   100     iDivert->SetDivertingL( aDivert, aBsc );
       
   101     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetDivertingL" );
       
   102     }
       
   103 
       
   104 // --------------------------------------------------------------------------- 
       
   105 // Request diverting status from network asynhronously.
       
   106 // ---------------------------------------------------------------------------
       
   107 EXPORT_C void CPsetCallDiverting::GetDivertingStatusL( 
       
   108     const TServiceGroup aServiceGroup,
       
   109     const TCallDivertingCondition aCondition, 
       
   110     TBasicServiceGroups aBsc ) 
       
   111     {
       
   112     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetDivertingStatusL" );
       
   113     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::GetDivertingStatusL: aServiceGroup: %d", aServiceGroup );
       
   114     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::GetDivertingStatusL: aCondition: %d", aCondition );
       
   115     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::GetDivertingStatusL: aBsc: %d", aBsc );
       
   116     iDivert->GetDivertingStatusL( aServiceGroup, aCondition, aBsc );
       
   117     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetDivertingStatusL" );
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // Cancels pending request.
       
   122 // ---------------------------------------------------------------------------
       
   123 EXPORT_C TInt CPsetCallDiverting::CancelCurrentRequest()
       
   124     {
       
   125     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::CancelCurrentRequest" );
       
   126     TInt err(KErrNone);
       
   127     err = iDivert->CancelCurrentRequest();
       
   128     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::CancelCurrentRequest" );
       
   129     return err; 
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // The default (last forwarded-to) numbers can be retrieved through this method.
       
   134 // The amount of available numbers is returned.
       
   135 // Relies on default numbers having right order in shared data.
       
   136 // ---------------------------------------------------------------------------
       
   137 EXPORT_C TInt CPsetCallDiverting::GetDefaultNumbersL( 
       
   138     CDesC16ArrayFlat& aDefNumbers )
       
   139     {
       
   140     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetDefaultNumbersL" );
       
   141     return iDivert->GetNumbersFromSharedDataL( NULL, aDefNumbers );
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // Sets new default number the the default numbers list, erases the oldest one.
       
   146 // ---------------------------------------------------------------------------
       
   147 EXPORT_C TInt CPsetCallDiverting::SetNewDefaultNumberL( TDes& aNumber )
       
   148     {
       
   149     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetNewDefaultNumberL" );
       
   150     TInt retValue(KErrNone);
       
   151     retValue = iDivert->SetNewDefaultNumberL( aNumber );
       
   152     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetNewDefaultNumberL" );
       
   153     return retValue; //return value is not used
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // Gets the timer value index related to "cfnry" from shared data
       
   158 // In error cases, return default value (30).
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 EXPORT_C TInt CPsetCallDiverting::GetTimerValueL()
       
   162     {
       
   163     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetTimerValueL" );
       
   164     TInt timerValue(0);
       
   165     timerValue = iDivert->GetTimerValueL();
       
   166     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetTimerValueL" );
       
   167     return timerValue;
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // Sets the default time for "divert when not answered" to .ini file
       
   172 // ---------------------------------------------------------------------------
       
   173 EXPORT_C TInt CPsetCallDiverting::SetTimerValueL( const TInt& aValue )
       
   174     {
       
   175     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetTimerValueL" );
       
   176     TInt retValue(KErrNone);
       
   177     retValue = iDivert->SetTimerValueL( aValue );
       
   178     __PHSLOGSTRING1("[PHS] <--CPsetCallDiverting::SetTimerValueL: retValue: %d", retValue );
       
   179     return retValue; 
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // Swaps the most recently used number to first in the shared data file.
       
   184 // ---------------------------------------------------------------------------
       
   185 EXPORT_C void CPsetCallDiverting::SwapDefaultNumberL( const TInt& aLocation )
       
   186     {
       
   187     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SwapDefaultNumberL" );
       
   188     iDivert->SwapDefaultNumberL( aLocation );
       
   189     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SwapDefaultNumberL" );
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // Saves fax call diverting number to shareddata.
       
   194 // ---------------------------------------------------------------------------
       
   195 EXPORT_C TInt CPsetCallDiverting::SetUsedDataNumberL(  TTelNumber& aNumber ) 
       
   196     {
       
   197     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetUsedDataNumberL" );
       
   198     TInt retValue = KErrNone;
       
   199     retValue = iDivert->SaveKey( KSettingsCFUsedDataNumber, aNumber );
       
   200     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetUsedDataNumberL: aNumber: %S", &aNumber );
       
   201     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetUsedDataNumberL: retValue: %d", retValue );
       
   202     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetUsedDataNumberL" );
       
   203     return retValue;
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // Returns used number for data call forwardings.
       
   208 // ---------------------------------------------------------------------------
       
   209 EXPORT_C HBufC* CPsetCallDiverting::GetUsedDataNumberLC( ) 
       
   210     {
       
   211     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetUsedDataNumberLC" );
       
   212     TTelNumber readNumber;
       
   213 
       
   214     iRepository->Get( KSettingsCFUsedDataNumber, readNumber );
       
   215 
       
   216     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::GetUsedDataNumberLC: readNumber: %S", &readNumber );
       
   217     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetUsedDataNumberLC" );
       
   218     
       
   219     return readNumber.AllocLC();
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 // Saves fax call diverting number to shareddata.
       
   224 // ---------------------------------------------------------------------------
       
   225 EXPORT_C TInt CPsetCallDiverting::SetUsedFaxNumberL(  TTelNumber& aNumber ) 
       
   226     {
       
   227     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::SetUsedFaxNumberL" );
       
   228     TInt retValue = KErrNone;
       
   229 
       
   230     retValue =  iDivert->SaveKey( KSettingsCFUsedFaxNumber, aNumber );
       
   231 
       
   232     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetUsedFaxNumberL: aNumber: %S", &aNumber );
       
   233     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::SetUsedFaxNumberL: retValue: %d", retValue );
       
   234     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::SetUsedFaxNumberL" );
       
   235 
       
   236     return retValue;
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // Returns used number for fax call forwardings.
       
   241 // ---------------------------------------------------------------------------
       
   242 EXPORT_C HBufC* CPsetCallDiverting::GetUsedFaxNumberLC() 
       
   243     {
       
   244     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::GetUsedFaxNumberLC" );
       
   245     TTelNumber readNumber;
       
   246 
       
   247     iRepository->Get( KSettingsCFUsedFaxNumber, readNumber );
       
   248 
       
   249     __PHSLOGSTRING1("[PHS]    CPsetCallDiverting::GetUsedFaxNumberLC: readNumber: %S", &readNumber );
       
   250     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::GetUsedFaxNumberLC" );
       
   251 
       
   252     return readNumber.AllocLC();
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // Sets request observer.
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C void CPsetCallDiverting::SetRequestObserver( MPsetRequestObserver* aObs )
       
   260     {
       
   261     iReqObserver = aObs;
       
   262     iDivert->SetRequestObserver(aObs);
       
   263     }
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // Queries for voice mail box number
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 EXPORT_C void CPsetCallDiverting::VoiceMailQueryL( TDes& /*aTelNumber*/ )
       
   270     {
       
   271     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::VoiceMailQueryL" );
       
   272 
       
   273     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::VoiceMailQueryL" );
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // Queries for voice mail box number
       
   278 // ---------------------------------------------------------------------------
       
   279 //
       
   280 EXPORT_C void CPsetCallDiverting::VideoMailQueryL( TDes& /*aTelNumber*/ )
       
   281     {
       
   282     __PHSLOGSTRING("[PHS]--> CPsetCallDiverting::VideoMailQueryL" );
       
   283 
       
   284     __PHSLOGSTRING("[PHS] <--CPsetCallDiverting::VideoMailQueryL" );
       
   285     }    
       
   286     
       
   287 // ---------------------------------------------------------------------------
       
   288 // Opens Vmbx. Leaves vmbx to the stack. 
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 TInt CPsetCallDiverting::OpenVideoMailboxLC( TDes& /*aTelNumber*/, RVmbxNumber& /*aVmbx*/ )
       
   292     {
       
   293     return 0;
       
   294     }
       
   295     
       
   296 // End of File