omaprovisioning/provisioning/WAPAdapter/Src/CWPWAPAdapterBase.cpp
changeset 0 b497e44ab2fc
child 24 bf47f3b79154
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Base for WAP adapters.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include <commdb.h>
       
    23 #include <ApDataHandler.h>
       
    24 #include <CWPAdapter.h>
       
    25 #include <CWPCharacteristic.h>
       
    26 #include <CWPParameter.h>
       
    27 #include <wpwapadapterresource.rsg>
       
    28 #include "CWPWAPItemBAse.h"
       
    29 #include "CWPWAPAdapterBase.h"
       
    30 #include "WPWAPDebug.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CWPWAPAdapterBase::CWPWAPAdapterBase
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CWPWAPAdapterBase::CWPWAPAdapterBase()
       
    41     : CWPAdapter()
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CWPWAPAdapterBase::BaseConstructL
       
    47 // 2nd phase base class constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 void CWPWAPAdapterBase::BaseConstructL()
       
    51     {
       
    52     }
       
    53 
       
    54 // Destructor
       
    55 CWPWAPAdapterBase::~CWPWAPAdapterBase()
       
    56     {
       
    57     iItems.ResetAndDestroy();
       
    58     iHiddenItems.ResetAndDestroy();
       
    59     delete iCommsDb;
       
    60     delete iAPHandler;
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CWPWAPAdapterBase::SummaryCount
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 TInt CWPWAPAdapterBase::ItemCount() const
       
    68     {
       
    69     return iItems.Count();
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CWPWAPAdapterBase::SummaryTitle
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 const TDesC16& CWPWAPAdapterBase::SummaryTitle(TInt aIndex) const
       
    77     {
       
    78     return iItems[aIndex]->Title();
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CWPWAPAdapterBase::SummaryText
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 const TDesC& CWPWAPAdapterBase::SummaryText(TInt aIndex) const
       
    86     {
       
    87     return iItems[aIndex]->Name();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CWPWAPAdapterBase::SaveL
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CWPWAPAdapterBase::SaveL(TInt aIndex)
       
    95     {
       
    96     iItems[aIndex]->SaveL();
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CWPWAPAdapterBase::CanSetAsDefault
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TBool CWPWAPAdapterBase::CanSetAsDefault(TInt aIndex) const
       
   104     {
       
   105     return iItems[aIndex]->CanSetAsDefault();
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CWPWAPAdapterBase::SetAsDefaultL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CWPWAPAdapterBase::SetAsDefaultL(TInt aIndex)
       
   113     {
       
   114     iItems[aIndex]->SetAsDefaultL();
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CWPWAPAdapterBase::DetailsL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TInt CWPWAPAdapterBase::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/ )
       
   122     {
       
   123     return KErrNotSupported;
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CWPWAPAdapterBase::VisitL
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CWPWAPAdapterBase::VisitL( CWPCharacteristic& aCharacteristic )
       
   131     {
       
   132     switch( aCharacteristic.Type() )
       
   133         {
       
   134         case KWPApplication:
       
   135             {
       
   136             aCharacteristic.AcceptL( *this );
       
   137             ApplicationL( aCharacteristic );
       
   138             iAppID.Set( KNullDesC );
       
   139             break;
       
   140             }
       
   141 
       
   142         default:
       
   143             {
       
   144             break;
       
   145             }
       
   146         }
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CWPWAPAdapterBase::VisitL
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 void CWPWAPAdapterBase::VisitL( CWPParameter& aParameter )
       
   154     {
       
   155     if( aParameter.ID() == EWPParameterAppID )
       
   156         {
       
   157         iAppID.Set( aParameter.Value() );
       
   158         }
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CWPWAPAdapterBase::VisitL
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CWPWAPAdapterBase::VisitLinkL( CWPCharacteristic& /*aLink*/ )
       
   166     {
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CWPWAPAdapterBase::ContextExtension
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 TInt CWPWAPAdapterBase::ContextExtension( MWPContextExtension*& aExtension )
       
   174     {
       
   175     aExtension = this;
       
   176     return KErrNone;
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CWPWAPAdapterBase::SaveDataL
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 const TDesC8& CWPWAPAdapterBase::SaveDataL( TInt aIndex ) const
       
   184     {
       
   185     return iItems[aIndex]->SaveData();
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CWPWAPAdapterBase::DeleteL
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CWPWAPAdapterBase::DeleteL( const TDesC8& aSaveData )
       
   193     {
       
   194     CreateDbL();
       
   195 
       
   196     TPckgBuf<MWPWAPItemBase::TWPWAPSaveItem> pckg;
       
   197     pckg.Copy( aSaveData );
       
   198 
       
   199     // Base class handles only access point deletion
       
   200     if( pckg().iSaveItemType == KWPWAPItemTypeAccesspoint )
       
   201         {
       
   202         DVA( "DeleteL: Deleting access point %08x", pckg().iUID );
       
   203         TRAPD( err, iAPHandler->RemoveAPL( pckg().iUID ) );
       
   204         DVA( "DeleteL: Deleted, %d", err );
       
   205         
       
   206         switch( err )
       
   207             {
       
   208             case KErrNotFound:
       
   209                 {
       
   210                 // Item not existing is what we want, so this error is ok
       
   211                 break;
       
   212                 }
       
   213                 
       
   214             case KErrLocked:
       
   215                 {
       
   216                 // Transform the code so that the caller can retry
       
   217                 User::Leave( EWPCommsDBLocked );
       
   218                 break;
       
   219                 }
       
   220                 
       
   221             default:
       
   222                 {
       
   223                 User::LeaveIfError( err );
       
   224                 break;
       
   225                 }
       
   226             }
       
   227         }
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CWPWAPAdapterBase::Uid
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 TUint32 CWPWAPAdapterBase::Uid() const
       
   235     {
       
   236     return iDtor_ID_Key.iUid;
       
   237     }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CWPWAPAdapterBase::CreateDbL
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 void CWPWAPAdapterBase::CreateDbL()
       
   244     {
       
   245     if( !iCommsDb )
       
   246         {
       
   247         iCommsDb = CCommsDatabase::NewL();
       
   248         }
       
   249 
       
   250     if( !iAPHandler )
       
   251         {
       
   252         iAPHandler = CApDataHandler::NewLC( *iCommsDb );
       
   253         CleanupStack::Pop(); // iAPEngine
       
   254         }
       
   255     }
       
   256 
       
   257 //  End of File