locationsystemui/locationsysui/locverifier/src/lpdsuplsettingsadapter.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2006 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:  Adapter to the SUPL Settings API
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includes
       
    20 #include <epos_csuplsettings.h>
       
    21 #include <locsuplsettingsui.rsg>
       
    22 #include <StringLoader.h>
       
    23 
       
    24 // User Includes
       
    25 #include "lpdsuplsettingsadapter.h"
       
    26 #include "lpdsuplsettingsadapterobserver.h"
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // Private Constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CLpdSUPLSettingsAdapter::CLpdSUPLSettingsAdapter( 
       
    34                             MLpdSUPLSettingsAdapterObserver&    aObserver )
       
    35 		:iObserver( aObserver )
       
    36     {
       
    37     }
       
    38  
       
    39 // ---------------------------------------------------------------------------
       
    40 // Destructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //    
       
    43 CLpdSUPLSettingsAdapter::~CLpdSUPLSettingsAdapter()
       
    44     {
       
    45    // delete iTimer;
       
    46     if( iSUPLSettings )
       
    47         {
       
    48         iSUPLSettings->RemoveSessionObserver();
       
    49         }
       
    50         
       
    51     delete iSUPLSettings;
       
    52     iSUPLSettings = NULL;	
       
    53 
       
    54     } 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CLpdSUPLSettingsAdapter* CLpdSUPLSettingsAdapter::NewL
       
    58 // Static Two phase contructor that instantiates the CLpdSUPLSettingsAdapter
       
    59 // 
       
    60 // @param aObserver				    Observer to the SUPL settings adapter
       
    61 // @return CLpdSUPLSettingsAdapter*	Reference to the object created
       
    62 // ---------------------------------------------------------------------------
       
    63 //    
       
    64 CLpdSUPLSettingsAdapter* CLpdSUPLSettingsAdapter::NewL(
       
    65                             MLpdSUPLSettingsAdapterObserver&    aObserver )
       
    66     {
       
    67     CLpdSUPLSettingsAdapter* self = 
       
    68                 new ( ELeave ) CLpdSUPLSettingsAdapter( aObserver );
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop( self );	
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // void CLpdSUPLSettingsAdapter::ConstructL
       
    77 // Second phase of the two phase constructor
       
    78 // ---------------------------------------------------------------------------
       
    79 // 
       
    80 void CLpdSUPLSettingsAdapter::ConstructL()
       
    81     {
       
    82     // Create the SUPL Settings
       
    83     iSUPLSettings = CSuplSettings::NewL();
       
    84     
       
    85     // Set the Observer for SUPL Sessions
       
    86     iSUPLSettings->SetSessionObserverL( *this );
       
    87    
       
    88     }  
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // void CLpdSUPLSettingsAdapter::HandleSuplSessionChangeL
       
    92 // Handle the Supl Session changes
       
    93 // ---------------------------------------------------------------------------
       
    94 //     
       
    95 void CLpdSUPLSettingsAdapter::HandleSuplSessionChangeL( 
       
    96                 TSuplSessionEventType aEvent,
       
    97                 TInt64 aSessionId                        
       
    98         		)
       
    99     {
       
   100 	if( aEvent == MSuplSessionObserver::ESuplSessionDBUpdateEvent ||
       
   101 		aEvent == MSuplSessionObserver::ESuplSessionDBDeleteEvent )
       
   102 		  {
       
   103       iObserver.UpdateSessionL( aSessionId );
       
   104 	    }	
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CLpdSUPLSettingsAdapter::GetSessionNameAndPeriodL
       
   109 // (other items were commented in a header).
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CLpdSUPLSettingsAdapter::GetTriggerPeriodL( TInt64 aSessionId, TUint& aTimePeriod )
       
   113     {
       
   114     CTriggerParams* trigParams = CTriggerParams::NewL();
       
   115     CleanupStack::PushL( trigParams );
       
   116      
       
   117     User::LeaveIfError( iSUPLSettings->GetTriggerParams( aSessionId, trigParams ) );
       
   118      
       
   119     TUint64 outstandingTrigger;
       
   120     TUint64 interval;
       
   121     TBool notificationPresent;
       
   122     TBool triggerNotificationStatus;  
       
   123     CTriggerParams::TTriggerType triggerType; 
       
   124     CTriggerParams::TRequestType requestType;
       
   125     
       
   126     HBufC* sessionName;
       
   127     sessionName = HBufC::NewLC( 256 ); 
       
   128                   
       
   129     sessionName->Des().Zero();
       
   130        
       
   131     User::LeaveIfError( trigParams->Get(
       
   132                              aSessionId, 
       
   133                              sessionName->Des(), 
       
   134                              notificationPresent, 
       
   135                              triggerNotificationStatus, 
       
   136                              triggerType,
       
   137                              requestType, 
       
   138                              outstandingTrigger, 
       
   139                              interval) );
       
   140     
       
   141     aTimePeriod = interval*outstandingTrigger;
       
   142     
       
   143     CleanupStack::PopAndDestroy( ); // sessionName
       
   144     CleanupStack::PopAndDestroy( ); // trigParams
       
   145     }
       
   146 
       
   147 // End of file