00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "FeatureChecker.h"
00017 #include <e32cons.h>
00018
00019 void CFeatureChecker::ConstructL()
00020 {
00021 iFeatNotifier = CFeatureNotifier::NewL(*this);
00022 }
00023
00024 CFeatureChecker* CFeatureChecker::NewL()
00025 {
00026 CFeatureChecker* self=new(ELeave)CFeatureChecker();
00027 CleanupStack::PushL(self);
00028 self->ConstructL();
00029 CleanupStack::Pop(self);
00030 return self;
00031 }
00032
00036 CFeatureChecker::~CFeatureChecker()
00037 {
00038 delete iFeatNotifier;
00039 }
00040
00044 void CFeatureChecker::NotifyFeatureL()
00045 {
00046 RFeatureUidArray featArray;
00047 CleanupClosePushL(featArray);
00048 TUid uidFeature;
00049
00050
00051 const TInt KNumFeaturesforNotification(10);
00052
00053
00054
00055 TUid KFeatureUidforNotification = {0x12000000};
00056
00057
00058 for( int k=0; k<=KNumFeaturesforNotification; k++)
00059 {
00060 uidFeature.iUid = KFeatureUidforNotification.iUid + k;
00061 featArray.Append(uidFeature);
00062 }
00063
00064
00065 User::LeaveIfError(iFeatNotifier->NotifyRequest(featArray));
00066 CleanupStack::PopAndDestroy(&featArray);
00067 }
00068
00072 void CFeatureChecker::HandleNotifyError(TInt )
00073 {
00074 }
00075
00081 void CFeatureChecker::HandleNotifyChange(TFeatureChangeType aType, TFeatureEntry )
00082 {
00083 const TInt KFeatureChangeTypeMaxSize(45);
00084 TBuf<KFeatureChangeTypeMaxSize> changetype;
00085 switch(aType)
00086 {
00087 case EFeatureNoChange:
00088 _LIT(KNoChange, "Feature status not changed");
00089 changetype.Copy(KNoChange);
00090 break;
00091 case EFeatureStatusUpdated :
00092 _LIT(KStatusUpdated, "Feature status changed to enabled or disabled");
00093 changetype.Copy(KStatusUpdated);
00094 break;
00095 case EFeatureDataUpdated:
00096 _LIT(KDataUpdated, "Feature data changed");
00097 changetype.Copy(KDataUpdated);
00098 break;
00099 case EFeatureStatusDataUpdated:
00100
00101 _LIT(KStatusDataUpdated, "Feature status and data changed");
00102 changetype.Copy(KStatusDataUpdated);
00103 break;
00104 case EFeatureRediscover:
00105
00106 _LIT(KFeatureRediscover, "Complex change occurred, reload all features");
00107 changetype.Copy(KFeatureRediscover);
00108 break;
00109 case EFeatureFeatureCreated:
00110 _LIT(KFeatureCreated, "New feature has been added to the system");
00111 changetype.Copy(KFeatureCreated);
00112 break;
00113 case EFeatureFeatureDeleted:
00114 _LIT(KFeatureDeleted, "Feature has been deleted");
00115 changetype.Copy(KFeatureDeleted);
00116 break;
00117 }
00118
00119 User::InfoPrint(changetype);
00120 }
00121
00126 static void MainL()
00127 {
00128 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
00129 CleanupStack::PushL(scheduler);
00130 CActiveScheduler::Install(scheduler);
00131
00132 CFeatureChecker* featChecker = CFeatureChecker::NewL();
00133 CleanupStack::PushL(featChecker);
00134
00135 featChecker->NotifyFeatureL();
00136 CActiveScheduler::Start();
00137
00138 CleanupStack::PopAndDestroy(featChecker);
00139 CleanupStack::PopAndDestroy(scheduler);
00140 }
00141
00142 extern TInt E32Main()
00143 {
00144
00145 __UHEAP_MARK;
00146 CTrapCleanup* cleanup = CTrapCleanup::New();
00147 if(cleanup == NULL)
00148 {
00149 return KErrNoMemory;
00150 }
00151
00152 TRAPD(mainError, MainL());
00153 if(mainError != KErrNone)
00154 {
00155 _LIT(KUserPanic,"Failed to complete");
00156 User::Panic(KUserPanic, mainError);
00157 }
00158 delete cleanup;
00159 __UHEAP_MARKEND;
00160 return KErrNone;
00161 }