supl/locationsuplfw/terminalinitiationapi/src/epos_suplterminalparams.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:  Implementation of class CSuplTerminalParams
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "epos_suplterminalparams.h"
       
    23 #include "epos_csuplsettingsconstants.h"
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // ==================== LOCAL FUNCTIONS ====================
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 //
       
    35 CSuplTerminalParams ::CSuplTerminalParams ():iSlpId (-1),
       
    36                                         iServerAddress (NULL),
       
    37                                         iIap (NULL),
       
    38                                         iServerEnabled(EFalse),                                            
       
    39                                         iSimChangeRemove  (EFalse),
       
    40                                         iUsageInHomeNw (EFalse),
       
    41                                         iEditable (EFalse),
       
    42                                         
       
    43                                         iIsValueSet(EFalse)
       
    44     {
       
    45     }
       
    46     
       
    47 //---------------------------------------------------------
       
    48 //CSuplTerminalParams::NewL
       
    49 //
       
    50 // (other items were commented in a header).
       
    51 // ---------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CSuplTerminalParams* CSuplTerminalParams::NewL()
       
    54     {
       
    55     CSuplTerminalParams* self = new (ELeave) CSuplTerminalParams();
       
    56 
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop(self);
       
    60 
       
    61     return self;
       
    62     }
       
    63     
       
    64 //---------------------------------------------------------
       
    65 //CSuplTerminalParams::NewLC
       
    66 //
       
    67 // (other items were commented in a header).
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 EXPORT_C CSuplTerminalParams* CSuplTerminalParams::NewLC()
       
    71     {
       
    72     CSuplTerminalParams* self = new (ELeave) CSuplTerminalParams();
       
    73 
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL();
       
    76     CleanupStack::Pop(self);
       
    77 
       
    78     return self;
       
    79     }
       
    80 
       
    81 //---------------------------------------------------------
       
    82 //CSuplTerminalParams::ConstructL
       
    83 //
       
    84 // (other items were commented in a header).
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 // EPOC default constructor can leave.
       
    88 void CSuplTerminalParams::ConstructL()
       
    89     {      
       
    90     }
       
    91 
       
    92 // Destructor
       
    93 EXPORT_C  CSuplTerminalParams::~CSuplTerminalParams()
       
    94     {
       
    95     if(iServerAddress)
       
    96         {
       
    97         delete iServerAddress;
       
    98         iServerAddress = NULL;
       
    99         }
       
   100 
       
   101     if(iIap)
       
   102         {
       
   103         delete iIap;
       
   104         iIap = NULL;
       
   105         }
       
   106     }
       
   107     
       
   108 //---------------------------------------------------------
       
   109 //CSuplTerminalParams::Set
       
   110 //
       
   111 // (other items were commented in a header).
       
   112 // ---------------------------------------------------------
       
   113 //
       
   114 EXPORT_C TInt CSuplTerminalParams::Set( const TDesC& aServerAddress,          
       
   115                 const TDesC& aIapName, const TBool aServerEnabled,
       
   116                 const TBool aSimChangeRemove, const TBool aUsageInHomeNw,
       
   117                 const TBool aEditable,const TInt64 aSlpId)
       
   118     {
       
   119     iIsValueSet = EFalse;
       
   120     iSlpId = aSlpId;
       
   121     if(aServerAddress.Length() > 0 && aServerAddress.Length() < KMaxHSLPAddrLen)
       
   122         {
       
   123         delete iServerAddress;
       
   124         iServerAddress = NULL;
       
   125         iServerAddress = HBufC::New(aServerAddress.Length());
       
   126         if(!iServerAddress)
       
   127             {
       
   128             return KErrNoMemory;
       
   129             }
       
   130         iServerAddress->Des().Copy(aServerAddress);
       
   131         }
       
   132     else
       
   133         return KErrArgument;
       
   134         
       
   135     if(aIapName.Length() > 0 && aIapName.Length() < KMaxIAPLen)
       
   136         {
       
   137         delete iIap;
       
   138         iIap = NULL;
       
   139         iIap = HBufC::New(aIapName.Length());
       
   140         if(!iIap)
       
   141             {
       
   142             return KErrNoMemory;
       
   143             }
       
   144         iIap->Des().Copy(aIapName);
       
   145         }
       
   146     else
       
   147         return KErrArgument;
       
   148 
       
   149     iServerEnabled = aServerEnabled;
       
   150     iSimChangeRemove = aSimChangeRemove;
       
   151     iUsageInHomeNw = aUsageInHomeNw;
       
   152     iEditable = aEditable;
       
   153     
       
   154     iIsValueSet = ETrue;
       
   155     return KErrNone;            
       
   156     }
       
   157     
       
   158 //---------------------------------------------------------
       
   159 //CSuplTerminalParams::Get
       
   160 //
       
   161 // (other items were commented in a header).
       
   162 // ---------------------------------------------------------
       
   163 //
       
   164 EXPORT_C TInt CSuplTerminalParams::Get(TInt64 &aSlpId, TPtr aServerAddress,         
       
   165                 TPtr aIapName,TBool& aServerEnabled,
       
   166                 TBool& aSimChangeRemove, TBool& aUsageInHomeNw, TBool& aEditable) const
       
   167     {
       
   168     if(!iIsValueSet) //if values were not set before using the Set method, return error
       
   169         return KErrNotFound;
       
   170     
       
   171     aSlpId = iSlpId;
       
   172     
       
   173     if(iServerAddress)
       
   174         aServerAddress = iServerAddress->Des();
       
   175     
       
   176     if(iIap)
       
   177         aIapName = iIap->Des();
       
   178     
       
   179     aServerEnabled = iServerEnabled;
       
   180     aSimChangeRemove = iSimChangeRemove;
       
   181     aUsageInHomeNw = iUsageInHomeNw;
       
   182     aEditable = iEditable;
       
   183     return KErrNone;            
       
   184     }
       
   185 
       
   186 //  End of File
       
   187