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 CPhoneApp.cpp
00030
00031
00032 #include "CPhoneId.h"
00033
00039 _LIT(KRegisteredManufacturer, "Generic");
00040 _LIT(KRegisteredModel, "123");
00041 _LIT(KRegisteredSerialNumber, "1234567890");
00042
00050 CPhoneId* CPhoneId::NewL(MExecAsync* aController)
00051 {
00052 CPhoneId* self = new(ELeave) CPhoneId(aController);
00053 CleanupStack::PushL(self);
00054 self->ConstructL();
00055 CleanupStack::Pop(self);
00056 return self;
00057 }
00058
00063 CPhoneId::~CPhoneId()
00064 {
00065 Cancel();
00066 }
00067
00071 void CPhoneId::DoStartRequestL()
00072 {
00073
00074 iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
00075 SetActive();
00076 }
00077
00084 CPhoneId::CPhoneId(MExecAsync* aController)
00085 : CISVAPIAsync(aController, KPhoneId),
00086 iPhoneIdV1Pckg(iPhoneIdV1)
00087 {
00088
00089 }
00090
00094 void CPhoneId::ConstructL()
00095 {
00096
00097 }
00098
00103 void CPhoneId::RunL()
00104 {
00105
00106 if(iStatus != KErrNone)
00107 {
00108 iConsole->Printf(KError);
00109
00110
00111 iConsole->Printf(_L("%d\n"), iStatus.Int());
00112 }
00113 else
00114 {
00115 if (AppRegistered())
00116 {
00117 TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer;
00118 TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel;
00119 TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber;
00120 iConsole->Printf(KPhoneIdMsg);
00121
00122
00123 iConsole->Printf(manufacturer);
00124 iConsole->Printf(KNewLine);
00125
00126
00127 iConsole->Printf(model);
00128 iConsole->Printf(KNewLine);
00129
00130
00131 iConsole->Printf(serialNumber);
00132 iConsole->Printf(KNewLine);
00133
00134 ExampleComplete();
00135 }
00136 else
00137 {
00138
00139
00140
00141
00142
00143 iConsole->Printf(_L("Application not registered to phone!\n"));
00144 iConsole->Printf(_L("Recify this to remove this delay\n"));
00145 User::After(5000000);
00146 ExampleComplete();
00147 }
00148 }
00149 }
00150
00154 void CPhoneId::DoCancel()
00155 {
00156
00157 iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
00158 }
00159
00166 TBool CPhoneId::AppRegistered()
00167 {
00168
00169 TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer;
00170 TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel;
00171 TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber;
00172
00173
00174 TBuf<CTelephony::KPhoneModelIdSize> registeredModel(KRegisteredModel);
00175 TBuf<CTelephony::KPhoneSerialNumberSize> registeredSerialNumber(KRegisteredSerialNumber);
00176 TBuf<CTelephony::KPhoneManufacturerIdSize> registeredManufacturer(KRegisteredManufacturer);
00177
00178 return registeredModel == model &&
00179 registeredManufacturer == manufacturer &&
00180 registeredSerialNumber == serialNumber ;
00181 }