os/persistentdata/featuremgmt/featureregistry/src/api/featreg_wrapper.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 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
// Implementation of wrapper API for querying support for features on a device, It 
sl@0
    15
// internally uses Feature Manager query APIs.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <e32uid.h>
sl@0
    20
#include <featdiscovery.h>  
sl@0
    21
#include "featregpan.h"
sl@0
    22
#include "featreg.h"
sl@0
    23
#include "featregcmn.h"
sl@0
    24
sl@0
    25
// Class to hold pointers to Cleanup stack & Feature Manager CFeatureDiscovery
sl@0
    26
// virtual methods from CBase that result in these _TZ entries being generated.
sl@0
    27
//NONSHARABLE_CLASS is used to remove _ZTI & _ZTV entry from def file . 
sl@0
    28
NONSHARABLE_CLASS (CImplFeatDisc ) : public CBase
sl@0
    29
	{
sl@0
    30
	public:
sl@0
    31
		static CImplFeatDisc* NewL();
sl@0
    32
		~CImplFeatDisc();
sl@0
    33
	private:
sl@0
    34
		CImplFeatDisc();
sl@0
    35
		void ConstructL();
sl@0
    36
	
sl@0
    37
	public:
sl@0
    38
	
sl@0
    39
	CFeatureDiscovery *iFeatDis;
sl@0
    40
	CTrapCleanup * iCleanup;
sl@0
    41
	};
sl@0
    42
	
sl@0
    43
sl@0
    44
CImplFeatDisc::CImplFeatDisc() :   
sl@0
    45
	iFeatDis( NULL ), 
sl@0
    46
	iCleanup(NULL)
sl@0
    47
	{
sl@0
    48
		
sl@0
    49
	}
sl@0
    50
	
sl@0
    51
CImplFeatDisc::~CImplFeatDisc()
sl@0
    52
	{
sl@0
    53
	delete iFeatDis;
sl@0
    54
	iFeatDis = 0;
sl@0
    55
	
sl@0
    56
	delete iCleanup;
sl@0
    57
	iCleanup = 0;
sl@0
    58
	}
sl@0
    59
sl@0
    60
void CImplFeatDisc::ConstructL()
sl@0
    61
    {
sl@0
    62
    iFeatDis = CFeatureDiscovery::NewL();
sl@0
    63
    }
sl@0
    64
	
sl@0
    65
sl@0
    66
CImplFeatDisc* CImplFeatDisc::NewL()
sl@0
    67
    {
sl@0
    68
    CImplFeatDisc* self = new( ELeave ) CImplFeatDisc();
sl@0
    69
    CleanupStack::PushL( self );
sl@0
    70
    self->ConstructL();
sl@0
    71
    CleanupStack::Pop( self );
sl@0
    72
sl@0
    73
    return self;
sl@0
    74
    }
sl@0
    75
sl@0
    76
sl@0
    77
/**
sl@0
    78
 * Dummy feature registry implementation object - never instantiated.
sl@0
    79
 * @internalComponent
sl@0
    80
 */
sl@0
    81
class RFeatureRegistry::TImpl
sl@0
    82
	{
sl@0
    83
	TUint32 iDummy;
sl@0
    84
	};
sl@0
    85
sl@0
    86
/**
sl@0
    87
 * Opens connection to the Feature Registry for making non-static queries.
sl@0
    88
 * Note all non-static queries return state at the time Open() was called;
sl@0
    89
 * Feature Registry changes are not observed until instance closed and re-opened.
sl@0
    90
 *
sl@0
    91
 * @return KErrNone if successful, negative system-wide error code if fails
sl@0
    92
 * @publishedPartner
sl@0
    93
 * @deprecated
sl@0
    94
 */
sl@0
    95
EXPORT_C TInt RFeatureRegistry::Open()
sl@0
    96
	{
sl@0
    97
	__ASSERT_ALWAYS(iImpl == NULL, Panic(EFeatRegInvalidUse));
sl@0
    98
	
sl@0
    99
	CTrapCleanup *cleanup = NULL;
sl@0
   100
	
sl@0
   101
	if(User::TrapHandler() == NULL)
sl@0
   102
		{
sl@0
   103
		cleanup = CTrapCleanup::New();	
sl@0
   104
		if(cleanup == NULL)
sl@0
   105
	        {
sl@0
   106
	        return KErrNoMemory;
sl@0
   107
	        }
sl@0
   108
		}
sl@0
   109
	
sl@0
   110
	CImplFeatDisc  *ptrh = NULL; 	
sl@0
   111
	TRAPD( err,  ptrh = CImplFeatDisc::NewL() );
sl@0
   112
    if ( err == KErrNone )
sl@0
   113
        {
sl@0
   114
    	ptrh->iCleanup = cleanup;
sl@0
   115
        iImpl = reinterpret_cast<TImpl*> (ptrh);
sl@0
   116
        }
sl@0
   117
    else
sl@0
   118
    	delete cleanup;
sl@0
   119
	return err;
sl@0
   120
	}
sl@0
   121
sl@0
   122
/**
sl@0
   123
 * Queries support for feature on the device.
sl@0
   124
 * Non-static version requiring open instance of class.
sl@0
   125
 * Recommended when making multiple queries.
sl@0
   126
 * Note: returns support for feature from the time Open() was called.
sl@0
   127
 *
sl@0
   128
 * @param aFeatureUid Unique identifier of feature being queried
sl@0
   129
 * @return positive value if feature is supported, zero if feature is not supported,
sl@0
   130
 *     or negative system-wide error code if could not be determined.
sl@0
   131
 * @pre this registry instance is open
sl@0
   132
 * @panic FeatReg EFeatRegInvalidUse if this registry instance is not open
sl@0
   133
 * @publishedPartner
sl@0
   134
 * @deprecated
sl@0
   135
 */
sl@0
   136
EXPORT_C TInt RFeatureRegistry::QuerySupport(TUid aFeatureUid)
sl@0
   137
	{
sl@0
   138
	
sl@0
   139
	TUint32 dummyInfo;
sl@0
   140
	return QuerySupport(aFeatureUid, dummyInfo);
sl@0
   141
	}
sl@0
   142
sl@0
   143
/**
sl@0
   144
 * Queries support for feature on the device.
sl@0
   145
 * Non-static version requiring open instance of class.
sl@0
   146
 * Recommended when making multiple queries.
sl@0
   147
 * Note: returns support for feature from the time Open() was called.
sl@0
   148
 *
sl@0
   149
 * @param aFeatureUid Unique identifier of feature being queried
sl@0
   150
 * @param aInfo addition status information about feature
sl@0
   151
 * @return positive value if feature is supported, zero if feature is not supported,
sl@0
   152
 *     or negative system-wide error code if could not be determined.
sl@0
   153
 * @pre this registry instance is open
sl@0
   154
 * @panic FeatReg EFeatRegInvalidUse if this registry instance is not open
sl@0
   155
 * @publishedPartner
sl@0
   156
 * @deprecated
sl@0
   157
 */
sl@0
   158
EXPORT_C TInt RFeatureRegistry::QuerySupport(TUid aFeatureUid, TUint32& aInfo)
sl@0
   159
	{
sl@0
   160
	__ASSERT_ALWAYS(iImpl != NULL, Panic(EFeatRegInvalidUse));
sl@0
   161
sl@0
   162
	CImplFeatDisc *ptrh  = reinterpret_cast<CImplFeatDisc*> (iImpl);
sl@0
   163
	
sl@0
   164
	if(ptrh->iFeatDis->IsSupported(aFeatureUid))
sl@0
   165
		{
sl@0
   166
		
sl@0
   167
		//FeatReg support only ROM features so EStatusUpgradableBit has no meaning
sl@0
   168
		//So aInfo always set to EStatusSupportBit in this wrapper
sl@0
   169
		aInfo = EStatusSupportBit;
sl@0
   170
		return EStatusSupportBit;		
sl@0
   171
		}
sl@0
   172
sl@0
   173
	// feature not supported
sl@0
   174
	aInfo =0;
sl@0
   175
	return 0;
sl@0
   176
	}
sl@0
   177
sl@0
   178
/**
sl@0
   179
 * Closes this registry instance.
sl@0
   180
 * @publishedPartner
sl@0
   181
 * @deprecated
sl@0
   182
 */
sl@0
   183
EXPORT_C void RFeatureRegistry::Close()
sl@0
   184
	{
sl@0
   185
	CImplFeatDisc *ptrh  = reinterpret_cast<CImplFeatDisc*> (iImpl);
sl@0
   186
	delete ptrh;
sl@0
   187
	ptrh = 0;
sl@0
   188
	}
sl@0
   189
sl@0
   190
/**
sl@0
   191
 * Queries support for feature on the device.
sl@0
   192
 * Static version recommended for single queries.
sl@0
   193
 *
sl@0
   194
 * @param aFeatureUid Unique identifier of feature being queried
sl@0
   195
 * @return positive value if feature is supported, zero if feature is not supported,
sl@0
   196
 *     or negative system-wide error code if could not be determined.
sl@0
   197
 * @publishedPartner
sl@0
   198
 * @deprecated
sl@0
   199
 */
sl@0
   200
EXPORT_C TInt RFeatureRegistry::QuerySupportS(TUid aFeatureUid)
sl@0
   201
	{
sl@0
   202
	TUint32 dummyInfo;
sl@0
   203
	return QuerySupportS(aFeatureUid, dummyInfo);
sl@0
   204
	}
sl@0
   205
sl@0
   206
/**
sl@0
   207
 * Queries support for feature on the device.
sl@0
   208
 * Static version recommended for single queries.
sl@0
   209
 *
sl@0
   210
 * @param aFeatureUid Unique identifier of feature being queried
sl@0
   211
 * @param aInfo addition status information about feature
sl@0
   212
 * @return positive value if feature is supported, zero if feature is not supported,
sl@0
   213
 *     or negative system-wide error code if could not be determined.
sl@0
   214
 * @publishedPartner
sl@0
   215
 * @deprecated
sl@0
   216
 */
sl@0
   217
EXPORT_C TInt RFeatureRegistry::QuerySupportS(TUid aFeatureUid, TUint32& aInfo)
sl@0
   218
	{
sl@0
   219
	CTrapCleanup * cleanup = NULL;
sl@0
   220
	if(User::TrapHandler() == NULL)
sl@0
   221
		{
sl@0
   222
		cleanup = CTrapCleanup::New();
sl@0
   223
		if(cleanup == NULL)
sl@0
   224
	        {
sl@0
   225
	        return KErrNoMemory;
sl@0
   226
	        }
sl@0
   227
		}
sl@0
   228
	TBool supported = EFalse;
sl@0
   229
	TRAPD( err,  supported = CFeatureDiscovery::IsFeatureSupportedL(aFeatureUid) );
sl@0
   230
	
sl@0
   231
	if(cleanup != NULL)
sl@0
   232
		delete cleanup;
sl@0
   233
     
sl@0
   234
	if (err != KErrNone)
sl@0
   235
		{
sl@0
   236
		return err;
sl@0
   237
		}
sl@0
   238
		
sl@0
   239
    if ( supported)
sl@0
   240
        {
sl@0
   241
		//FeatReg support only ROM features so EStatusUpgradableBit has no meaning
sl@0
   242
		//So aInfo always set to EStatusSupportBit in this wrapper
sl@0
   243
		aInfo = EStatusSupportBit;
sl@0
   244
		return EStatusSupportBit;		
sl@0
   245
        }
sl@0
   246
   
sl@0
   247
	// feature not supported
sl@0
   248
	aInfo =0;
sl@0
   249
	return 0;
sl@0
   250
sl@0
   251
	}
sl@0
   252
	
sl@0
   253
sl@0
   254
// CLASS DECLARATION
sl@0
   255
sl@0
   256
/**
sl@0
   257
Dummy class. Contains placeholder for a removed RFeatureRegistryNotify function to prevent BC break.
sl@0
   258
@internalComponent
sl@0
   259
*/
sl@0
   260
class Dummy
sl@0
   261
    {
sl@0
   262
sl@0
   263
    public: // New functions
sl@0
   264
sl@0
   265
        IMPORT_C static void Dummy1();
sl@0
   266
        IMPORT_C static void Dummy2();
sl@0
   267
        IMPORT_C static TInt Dummy3();
sl@0
   268
        IMPORT_C static void Dummy4(TRequestStatus &);
sl@0
   269
    };
sl@0
   270
sl@0
   271
// ================= MEMBER FUNCTIONS =======================
sl@0
   272
sl@0
   273
sl@0
   274
/**
sl@0
   275
Dummy method
sl@0
   276
@internalComponent
sl@0
   277
*/
sl@0
   278
EXPORT_C void Dummy::Dummy1() { }
sl@0
   279
sl@0
   280
/**
sl@0
   281
Dummy method
sl@0
   282
@internalComponent
sl@0
   283
*/
sl@0
   284
EXPORT_C void Dummy::Dummy2() {  }
sl@0
   285
/**
sl@0
   286
Dummy method
sl@0
   287
@internalComponent
sl@0
   288
@return KErrNotSupported
sl@0
   289
*/
sl@0
   290
EXPORT_C TInt Dummy::Dummy3() 
sl@0
   291
{  
sl@0
   292
return KErrNotSupported;
sl@0
   293
}
sl@0
   294
sl@0
   295
/**
sl@0
   296
Dummy method
sl@0
   297
@internalComponent
sl@0
   298
*/
sl@0
   299
EXPORT_C void Dummy::Dummy4(TRequestStatus &) {  }
sl@0
   300
sl@0
   301
sl@0
   302
sl@0
   303
sl@0
   304