os/persistentdata/featuremgmt/featuremgr/src/clientdll/featmgrtlsdata.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
sl@0
    18
// INCLUDE FILES
sl@0
    19
#include <featmgr/featmgr.h>
sl@0
    20
#include "featmgrtlsdata.h"
sl@0
    21
#include "featmgrdebug.h"
sl@0
    22
sl@0
    23
// ============================= LOCAL FUNCTIONS ===============================
sl@0
    24
sl@0
    25
static CFeatMgrTlsData* TlsData( )
sl@0
    26
    {
sl@0
    27
    CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() );
sl@0
    28
    _LIT( KPanicCategory, "RFeatureControl" );
sl@0
    29
    __ASSERT_ALWAYS( tlsData, User::Panic( KPanicCategory, EPanicBadHandle ) );
sl@0
    30
sl@0
    31
    return tlsData;
sl@0
    32
    }
sl@0
    33
sl@0
    34
sl@0
    35
EXPORT_C TInt GetClientCount( )
sl@0
    36
    {
sl@0
    37
        CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() );
sl@0
    38
        if (tlsData)
sl@0
    39
            {
sl@0
    40
            return tlsData->ClientCount();
sl@0
    41
            }
sl@0
    42
        else
sl@0
    43
            {
sl@0
    44
            return 0;
sl@0
    45
            }
sl@0
    46
    }
sl@0
    47
sl@0
    48
// ============================ MEMBER FUNCTIONS ===============================
sl@0
    49
sl@0
    50
// -----------------------------------------------------------------------------
sl@0
    51
// CFeatureManager::CFeatureManager()
sl@0
    52
// -----------------------------------------------------------------------------
sl@0
    53
//
sl@0
    54
sl@0
    55
CFeatMgrTlsData::CFeatMgrTlsData() :
sl@0
    56
    iClientCount(0)
sl@0
    57
    {
sl@0
    58
    }
sl@0
    59
sl@0
    60
// -----------------------------------------------------------------------------
sl@0
    61
// CFeatureManager::ConstructL
sl@0
    62
// -----------------------------------------------------------------------------
sl@0
    63
//
sl@0
    64
void CFeatMgrTlsData::ConstructL()
sl@0
    65
    {
sl@0
    66
    // Connect to Feature Manager server
sl@0
    67
    FUNC_LOG
sl@0
    68
    TInt err( iFeatMgrClient.Connect() );
sl@0
    69
    User::LeaveIfError(err);
sl@0
    70
    }
sl@0
    71
sl@0
    72
// -----------------------------------------------------------------------------
sl@0
    73
// CFeatureManager::NewL()
sl@0
    74
// Two-phased constructor.
sl@0
    75
// -----------------------------------------------------------------------------
sl@0
    76
//
sl@0
    77
CFeatMgrTlsData* CFeatMgrTlsData::NewL()
sl@0
    78
    {
sl@0
    79
    CFeatMgrTlsData* self = new( ELeave ) CFeatMgrTlsData();
sl@0
    80
    CleanupStack::PushL( self );
sl@0
    81
    self->ConstructL();
sl@0
    82
    CleanupStack::Pop( self );
sl@0
    83
    return self;
sl@0
    84
    }
sl@0
    85
    
sl@0
    86
// -----------------------------------------------------------------------------
sl@0
    87
// CFeatureManager::~CFeatMgrTlsData
sl@0
    88
// -----------------------------------------------------------------------------
sl@0
    89
//
sl@0
    90
CFeatMgrTlsData::~CFeatMgrTlsData()
sl@0
    91
    {
sl@0
    92
    FUNC_LOG
sl@0
    93
    iFeatMgrClient.Close();
sl@0
    94
    }
sl@0
    95
sl@0
    96
// -----------------------------------------------------------------------------
sl@0
    97
// CFeatMgrTlsData::CanBeFreed()
sl@0
    98
// -----------------------------------------------------------------------------
sl@0
    99
//
sl@0
   100
TBool CFeatMgrTlsData::CanBeFreed() const
sl@0
   101
    {
sl@0
   102
	if (iClientCount <= 0)
sl@0
   103
	    {
sl@0
   104
		INFO_LOG1( "FeatMgr: TLS can be freed, clients(%d)", iClientCount );
sl@0
   105
		return ETrue;
sl@0
   106
	    }
sl@0
   107
	else
sl@0
   108
	    {
sl@0
   109
		INFO_LOG1( "FeatMgr: TLS can NOT be freed, clients(%d)", iClientCount );
sl@0
   110
		return EFalse;
sl@0
   111
	    }
sl@0
   112
    }
sl@0
   113
sl@0
   114
// -----------------------------------------------------------------------------
sl@0
   115
// CFeatMgrTlsData::IncreaseClientCount()
sl@0
   116
// -----------------------------------------------------------------------------
sl@0
   117
//
sl@0
   118
void CFeatMgrTlsData::IncreaseClientCount()
sl@0
   119
    {
sl@0
   120
	++iClientCount;
sl@0
   121
	INFO_LOG1( "FeatMgr: TLS increase, clients now(%d)", iClientCount );
sl@0
   122
    }
sl@0
   123
sl@0
   124
// -----------------------------------------------------------------------------
sl@0
   125
// CFeatMgrTlsData::DecreaseClientCount()
sl@0
   126
// -----------------------------------------------------------------------------
sl@0
   127
//
sl@0
   128
sl@0
   129
void CFeatMgrTlsData::DecreaseClientCount()
sl@0
   130
    {
sl@0
   131
	--iClientCount;
sl@0
   132
	INFO_LOG1( "FeatMgr: TLS decrease, clients now(%d)", iClientCount );
sl@0
   133
    }
sl@0
   134
sl@0
   135
// -----------------------------------------------------------------------------
sl@0
   136
// CFeatMgrTlsData::ClientCount()
sl@0
   137
// -----------------------------------------------------------------------------
sl@0
   138
//
sl@0
   139
TInt CFeatMgrTlsData::ClientCount()
sl@0
   140
    {
sl@0
   141
        return iClientCount;
sl@0
   142
    }
sl@0
   143
// -----------------------------------------------------------------------------
sl@0
   144
// CFeatMgrTlsData::FeatureSupported()
sl@0
   145
// -----------------------------------------------------------------------------
sl@0
   146
//
sl@0
   147
TInt CFeatMgrTlsData::FeatureSupported( TFeatureEntry& aFeature ) const
sl@0
   148
    {
sl@0
   149
    return iFeatMgrClient.FeatureSupported( aFeature );
sl@0
   150
    }
sl@0
   151
sl@0
   152
// -----------------------------------------------------------------------------
sl@0
   153
// CFeatMgrTlsData::FeaturesSupported()
sl@0
   154
// -----------------------------------------------------------------------------
sl@0
   155
//
sl@0
   156
TInt CFeatMgrTlsData::FeaturesSupported( RFeatureArray& aFeatures )
sl@0
   157
    {
sl@0
   158
    return iFeatMgrClient.FeaturesSupported( aFeatures );
sl@0
   159
    }
sl@0
   160
sl@0
   161
// -----------------------------------------------------------------------------
sl@0
   162
// CFeatMgrTlsData::EnableFeature()
sl@0
   163
// -----------------------------------------------------------------------------
sl@0
   164
//
sl@0
   165
TInt CFeatMgrTlsData::EnableFeature( TUid aFeature ) const
sl@0
   166
    {
sl@0
   167
    return iFeatMgrClient.EnableFeature( aFeature );
sl@0
   168
    }
sl@0
   169
sl@0
   170
// -----------------------------------------------------------------------------
sl@0
   171
// CFeatMgrTlsData::DisableFeature()
sl@0
   172
// -----------------------------------------------------------------------------
sl@0
   173
//
sl@0
   174
TInt CFeatMgrTlsData::DisableFeature( TUid aFeature ) const
sl@0
   175
    {
sl@0
   176
    return iFeatMgrClient.DisableFeature( aFeature );
sl@0
   177
    }
sl@0
   178
    
sl@0
   179
// -----------------------------------------------------------------------------
sl@0
   180
// CFeatMgrTlsData::SetFeature()
sl@0
   181
// -----------------------------------------------------------------------------
sl@0
   182
//
sl@0
   183
TInt CFeatMgrTlsData::SetFeature( TUid aFeature, TBool aEnabled, TInt aData ) const
sl@0
   184
    {
sl@0
   185
    return iFeatMgrClient.SetFeature( aFeature, aEnabled, aData );
sl@0
   186
    }
sl@0
   187
sl@0
   188
// -----------------------------------------------------------------------------
sl@0
   189
// CFeatMgrTlsData::SetFeature()
sl@0
   190
// -----------------------------------------------------------------------------
sl@0
   191
//
sl@0
   192
TInt CFeatMgrTlsData::SetFeature( TUid aFeature, TInt aData ) const
sl@0
   193
    {
sl@0
   194
    return iFeatMgrClient.SetFeature( aFeature, aData );
sl@0
   195
    }
sl@0
   196
sl@0
   197
// -----------------------------------------------------------------------------
sl@0
   198
// CFeatMgrTlsData::AddFeature()
sl@0
   199
// -----------------------------------------------------------------------------
sl@0
   200
//
sl@0
   201
TInt CFeatMgrTlsData::AddFeature( TFeatureEntry aFeature ) const
sl@0
   202
    {
sl@0
   203
    return iFeatMgrClient.AddFeature( aFeature );
sl@0
   204
    }
sl@0
   205
sl@0
   206
// -----------------------------------------------------------------------------
sl@0
   207
// CFeatMgrTlsData::DeleteFeature()
sl@0
   208
// -----------------------------------------------------------------------------
sl@0
   209
//
sl@0
   210
TInt CFeatMgrTlsData::DeleteFeature( TUid aFeature ) const
sl@0
   211
    {
sl@0
   212
    return iFeatMgrClient.DeleteFeature( aFeature );
sl@0
   213
    }
sl@0
   214
sl@0
   215
// -----------------------------------------------------------------------------
sl@0
   216
// CFeatMgrTlsData::ListSupportedFeaturesL()
sl@0
   217
// -----------------------------------------------------------------------------
sl@0
   218
//
sl@0
   219
void CFeatMgrTlsData::ListSupportedFeaturesL( RFeatureUidArray& aSupportedFeatures )
sl@0
   220
    {
sl@0
   221
    iFeatMgrClient.ListSupportedFeaturesL( aSupportedFeatures );
sl@0
   222
    }
sl@0
   223
sl@0
   224
// -----------------------------------------------------------------------------
sl@0
   225
// CFeatMgrTlsData::ReRequestNotification(TUid&, TRequestStatus&)
sl@0
   226
// -----------------------------------------------------------------------------
sl@0
   227
//
sl@0
   228
void CFeatMgrTlsData::ReRequestNotification( TUid& aFeatUid, TRequestStatus& aStatus )
sl@0
   229
    {
sl@0
   230
    iFeatMgrClient.ReRequestNotification( aFeatUid, aStatus );
sl@0
   231
    }
sl@0
   232
        
sl@0
   233
sl@0
   234
// -----------------------------------------------------------------------------
sl@0
   235
// CFeatMgrTlsData::RequestNotification(RFeatureUidArray&, TUid&, TRequestStatus&)
sl@0
   236
// -----------------------------------------------------------------------------
sl@0
   237
//
sl@0
   238
TInt CFeatMgrTlsData::RequestNotification( RFeatureUidArray& aFeatures, TUid& aFeatUid, 
sl@0
   239
    TRequestStatus& aStatus )
sl@0
   240
    {
sl@0
   241
    return iFeatMgrClient.RequestNotification( aFeatures, aFeatUid, aStatus );
sl@0
   242
    }
sl@0
   243
        
sl@0
   244
// -----------------------------------------------------------------------------
sl@0
   245
// CFeatMgrTlsData::RequestNotifyCancel(RFeatureUidArray&, TRequestStatus&)
sl@0
   246
// -----------------------------------------------------------------------------
sl@0
   247
//
sl@0
   248
TInt CFeatMgrTlsData::RequestNotifyCancel( TUid aFeature ) const
sl@0
   249
    {
sl@0
   250
    return iFeatMgrClient.RequestNotifyCancel( aFeature );
sl@0
   251
    }
sl@0
   252
        
sl@0
   253
// -----------------------------------------------------------------------------
sl@0
   254
// CFeatMgrTlsData::RequestNotifyCancelAll(RFeatureUidArray&, TRequestStatus&)
sl@0
   255
// -----------------------------------------------------------------------------
sl@0
   256
//
sl@0
   257
TInt CFeatMgrTlsData::RequestNotifyCancelAll( ) const
sl@0
   258
    {
sl@0
   259
    return iFeatMgrClient.RequestNotifyCancelAll( );
sl@0
   260
    }
sl@0
   261
sl@0
   262
// -----------------------------------------------------------------------------
sl@0
   263
// CFeatMgrTlsData::DeleteClient()
sl@0
   264
// -----------------------------------------------------------------------------
sl@0
   265
//
sl@0
   266
void CFeatMgrTlsData::DeleteClient()
sl@0
   267
	{
sl@0
   268
	CFeatMgrTlsData* tlsData = TlsData();
sl@0
   269
sl@0
   270
	// Decrease the client count (self)
sl@0
   271
	tlsData->DecreaseClientCount();
sl@0
   272
sl@0
   273
	// Check if no more clients so that TLS can be freed.
sl@0
   274
	if (tlsData->CanBeFreed())
sl@0
   275
		{
sl@0
   276
		delete tlsData;
sl@0
   277
		Dll::SetTls( NULL );
sl@0
   278
		}
sl@0
   279
    }
sl@0
   280
sl@0
   281
// -----------------------------------------------------------------------------
sl@0
   282
// CFeatMgrTlsData::SWIStart()
sl@0
   283
// -----------------------------------------------------------------------------
sl@0
   284
//
sl@0
   285
TInt CFeatMgrTlsData::SWIStart( ) const
sl@0
   286
    {
sl@0
   287
    return iFeatMgrClient.SWIStart();
sl@0
   288
    }
sl@0
   289
sl@0
   290
// -----------------------------------------------------------------------------
sl@0
   291
// CFeatMgrTlsData::SWIEnd()
sl@0
   292
// -----------------------------------------------------------------------------
sl@0
   293
//
sl@0
   294
TInt CFeatMgrTlsData::SWIEnd( ) const
sl@0
   295
    {
sl@0
   296
    return iFeatMgrClient.SWIEnd(); 
sl@0
   297
	}
sl@0
   298
sl@0
   299
/////////////////////////////////////////////////////////////////////////////////
sl@0
   300
sl@0
   301
// debug only API functions
sl@0
   302
#ifdef EXTENDED_FEATURE_MANAGER_TEST
sl@0
   303
sl@0
   304
#pragma BullseyeCoverage off
sl@0
   305
sl@0
   306
/** 
sl@0
   307
*/
sl@0
   308
void CFeatMgrTlsData::ResourceMark()
sl@0
   309
    {
sl@0
   310
    iFeatMgrClient.ResourceMark();
sl@0
   311
    }
sl@0
   312
sl@0
   313
/** 
sl@0
   314
*/
sl@0
   315
void CFeatMgrTlsData::ResourceCheck()
sl@0
   316
    {
sl@0
   317
    iFeatMgrClient.ResourceCheck();
sl@0
   318
    }
sl@0
   319
sl@0
   320
/** 
sl@0
   321
*/
sl@0
   322
TInt CFeatMgrTlsData::ResourceCount()
sl@0
   323
    {
sl@0
   324
    return iFeatMgrClient.ResourceCount();
sl@0
   325
    }
sl@0
   326
sl@0
   327
/** 
sl@0
   328
*/
sl@0
   329
void CFeatMgrTlsData::SetHeapFailure(TInt aAllocFailType, TInt aRate)
sl@0
   330
    {
sl@0
   331
    iFeatMgrClient.SetHeapFailure(aAllocFailType, aRate);
sl@0
   332
    }
sl@0
   333
sl@0
   334
// -----------------------------------------------------------------------------
sl@0
   335
// CFeatMgrTlsData::NumberOfNotifyFeatures()
sl@0
   336
// -----------------------------------------------------------------------------
sl@0
   337
//
sl@0
   338
TInt CFeatMgrTlsData::NumberOfNotifyFeatures( void ) const
sl@0
   339
    {
sl@0
   340
    return iFeatMgrClient.NumberOfNotifyFeatures();
sl@0
   341
    }
sl@0
   342
// -----------------------------------------------------------------------------
sl@0
   343
// CFeatMgrTlsData::CountAllocCells()
sl@0
   344
// -----------------------------------------------------------------------------
sl@0
   345
//
sl@0
   346
TInt CFeatMgrTlsData::CountAllocCells( void ) const
sl@0
   347
    {
sl@0
   348
    return iFeatMgrClient.CountAllocCells();
sl@0
   349
    }
sl@0
   350
sl@0
   351
#pragma BullseyeCoverage on
sl@0
   352
sl@0
   353
#endif
sl@0
   354
sl@0
   355
//  End of File