00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CPhoneId.h"
00018
00024 _LIT(KRegisteredManufacturer, "Generic");
00025 _LIT(KRegisteredModel, "123");
00026 _LIT(KRegisteredSerialNumber, "1234567890");
00027
00035 CPhoneId* CPhoneId::NewL(MExecAsync* aController)
00036 {
00037 CPhoneId* self = new(ELeave) CPhoneId(aController);
00038 CleanupStack::PushL(self);
00039 self->ConstructL();
00040 CleanupStack::Pop(self);
00041 return self;
00042 }
00043
00048 CPhoneId::~CPhoneId()
00049 {
00050 Cancel();
00051 }
00052
00056 void CPhoneId::DoStartRequestL()
00057 {
00058
00059 iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
00060 SetActive();
00061 }
00062
00069 CPhoneId::CPhoneId(MExecAsync* aController)
00070 : CISVAPIAsync(aController, KPhoneId),
00071 iPhoneIdV1Pckg(iPhoneIdV1)
00072 {
00073
00074 }
00075
00079 void CPhoneId::ConstructL()
00080 {
00081
00082 }
00083
00088 void CPhoneId::RunL()
00089 {
00090
00091 if(iStatus != KErrNone)
00092 {
00093 iConsole->Printf(KError);
00094
00095
00096 iConsole->Printf(_L("%d\n"), iStatus.Int());
00097 }
00098 else
00099 {
00100 if (AppRegistered())
00101 {
00102 TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer;
00103 TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel;
00104 TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber;
00105 iConsole->Printf(KPhoneIdMsg);
00106
00107
00108 iConsole->Printf(manufacturer);
00109 iConsole->Printf(KNewLine);
00110
00111
00112 iConsole->Printf(model);
00113 iConsole->Printf(KNewLine);
00114
00115
00116 iConsole->Printf(serialNumber);
00117 iConsole->Printf(KNewLine);
00118
00119 ExampleComplete();
00120 }
00121 else
00122 {
00123
00124
00125
00126
00127
00128 iConsole->Printf(_L("Application not registered to phone!\n"));
00129 iConsole->Printf(_L("Recify this to remove this delay\n"));
00130 User::After(5000000);
00131 ExampleComplete();
00132 }
00133 }
00134 }
00135
00139 void CPhoneId::DoCancel()
00140 {
00141
00142 iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
00143 }
00144
00151 TBool CPhoneId::AppRegistered()
00152 {
00153
00154 TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer;
00155 TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel;
00156 TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber;
00157
00158
00159 TBuf<CTelephony::KPhoneModelIdSize> registeredModel(KRegisteredModel);
00160 TBuf<CTelephony::KPhoneSerialNumberSize> registeredSerialNumber(KRegisteredSerialNumber);
00161 TBuf<CTelephony::KPhoneManufacturerIdSize> registeredManufacturer(KRegisteredManufacturer);
00162
00163 return registeredModel == model &&
00164 registeredManufacturer == manufacturer &&
00165 registeredSerialNumber == serialNumber ;
00166 }