supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplsettings.cpp
changeset 0 667063e416a2
child 20 2b4ea9893b66
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:   class for holding SUPL settings
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <commdb.h>
       
    21 
       
    22 #include "epos_comasuplsettings.h"
       
    23 #include "epos_omasuplconstants.h"
       
    24 
       
    25 //Constructor
       
    26 COMASuplSettings::COMASuplSettings():iSettingsUIActive(EFalse)
       
    27 {
       
    28 }
       
    29 
       
    30 //Destructor
       
    31 COMASuplSettings::~COMASuplSettings()
       
    32 {
       
    33 	iHSLPIPAddress.Close();
       
    34 	iHSLPfromImsi.Close();
       
    35 }
       
    36 //
       
    37 // -----------------------------------------------------------------------------
       
    38 // CSuplSession::NewL
       
    39 // Creates new instance of COMASuplSession 
       
    40 // (other items were commented in a header).
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 COMASuplSettings* COMASuplSettings::NewL()
       
    44 { 	
       
    45 	COMASuplSettings* self = new( ELeave ) COMASuplSettings();
       
    46 	CleanupStack::PushL( self );
       
    47 	self->ConstructL();
       
    48 	CleanupStack::Pop(self);
       
    49 	return self;
       
    50 }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // COMASuplSettings::ConstuctL()
       
    54 // 2nd phase construction
       
    55 // (other items were commented in a header).
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 
       
    59 void COMASuplSettings::ConstructL()
       
    60 {
       
    61 	iHSLPIPAddress.CreateL(KMaxIPAddressLength);
       
    62 	iHSLPfromImsi.CreateL(KMaxIPAddressLength);
       
    63 }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // COMASuplSettings::SetHSLPAddress
       
    67 // Sets HSPLAddress 
       
    68 // (other items were commented in a header).
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void COMASuplSettings::SetIAPId(TInt aIAPId)
       
    72 {
       
    73 	iIAPId = aIAPId;
       
    74 }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // COMASuplSettings::SetHSLPAddress
       
    78 // Sets HSPLAddress 
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void COMASuplSettings::SetHSLPAddress(const TDesC& aHSLPIPAddress)
       
    83 {
       
    84 	iHSLPIPAddress.Append(aHSLPIPAddress);
       
    85 }
       
    86 // -----------------------------------------------------------------------------
       
    87 // COMASuplSettings::SetHSLPAddressfromIMSI
       
    88 // Sets HSPLAddress 
       
    89 // (other items were commented in a header).
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void COMASuplSettings::SetHSLPAddressFromIMSI(const TDesC& aHSLPfromImsi)
       
    93 {
       
    94 	iHSLPfromImsi.Append(aHSLPfromImsi);
       
    95 }	
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // COMASuplSettings::SLPAddress
       
    99 // This method returns SLPAddress
       
   100 // (other items were commented in a header).
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 const TDesC8& COMASuplSettings::SLPAddress() const
       
   104 {
       
   105 	return iHSLPIPAddress;
       
   106 }
       
   107 // -----------------------------------------------------------------------------
       
   108 // COMASuplSettings::SLPAddressfromIMSI
       
   109 // This method returns SLPAddress generated from IMSI
       
   110 // (other items were commented in a header).
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 const TDesC8& COMASuplSettings::SLPAddressfromImsi() const
       
   114 {
       
   115 	return iHSLPfromImsi;
       
   116 }
       
   117 // -----------------------------------------------------------------------------
       
   118 // COMASuplSettings::IAPId
       
   119 // This method returns IAPId.
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TInt COMASuplSettings::IAPId() const
       
   124 {
       
   125 	return iIAPId;
       
   126 }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // COMASuplSettings::SetSUPLUsage
       
   130 // Sets the SUPL Usage
       
   131 // 
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void COMASuplSettings::SetSUPLUsage(CSuplSettings::TSuplSettingsUsage& aSUPLUsage ) 
       
   135 {
       
   136     iSUPLUsage = aSUPLUsage;
       
   137 }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // COMASuplSettings::SUPLUsage() 
       
   141 // Gets the SUPL Usage
       
   142 // 
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 CSuplSettings::TSuplSettingsUsage COMASuplSettings::SUPLUsage() const
       
   146 	{
       
   147 		return iSUPLUsage;
       
   148 	}
       
   149 
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // COMASuplSettings::SetUIActive
       
   153 // Sets the flag indicating the activation of Settings UI
       
   154 // 
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 void COMASuplSettings::SetUIActive(TBool aIsActive)
       
   158 {
       
   159     iSettingsUIActive = aIsActive;
       
   160 }
       
   161 	
       
   162 // -----------------------------------------------------------------------------
       
   163 // COMASuplSettings::SetUIActive
       
   164 // Retrieves the flag indicating the activation of Settings UI
       
   165 // 
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 TBool COMASuplSettings::IsUIActive() const
       
   169 {
       
   170     return iSettingsUIActive;
       
   171 }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // COMASuplSettings::ConvertIAPNameToIdL
       
   175 // 
       
   176 // -----------------------------------------------------------------------------
       
   177 TBool COMASuplSettings::ConvertIAPNameToIdL(const TDesC& aIAPName, TUint32& aIAPId)
       
   178 	{
       
   179 		TBool result = EFalse;
       
   180 	
       
   181 		CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
       
   182 		CleanupStack::PushL(commDb);
       
   183 		CCommsDbTableView* tableView = commDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerCSD|ECommDbBearerGPRS,
       
   184 											ECommDbConnectionDirectionOutgoing);
       
   185 	   	TInt retval = tableView->GotoFirstRecord();
       
   186 	   	while ((retval == KErrNone) && (!result))
       
   187 	   	{
       
   188 	      HBufC * iap_name = tableView->ReadLongTextLC( TPtrC( COMMDB_NAME) );
       
   189 
       
   190 	      if (iap_name && (iap_name->Compare(aIAPName) == 0))
       
   191 	        {
       
   192 	           	tableView->ReadUintL(TPtrC(COMMDB_ID), aIAPId);
       
   193 	            result = ETrue;
       
   194 	       	}
       
   195 	       CleanupStack::PopAndDestroy(); // iap_name
       
   196 	       retval = tableView->GotoNextRecord();
       
   197 	   	}
       
   198 		CleanupStack::PopAndDestroy(2);//delete tableView and commDb
       
   199 		return result;
       
   200 	}
       
   201 	
       
   202 TBool COMASuplSettings::IsHslpNull() 
       
   203 {
       
   204     if(iHSLPIPAddress.Length()==0)
       
   205     	{
       
   206     		return ETrue;
       
   207     	}
       
   208     else
       
   209     	{
       
   210     		return EFalse;
       
   211     	}	
       
   212 }