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