00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // CPhoneApp.cpp 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 // Retrieves the model information and unique identification of the mobile device. 00059 iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg); 00060 SetActive(); 00061 } 00062 00069 CPhoneId::CPhoneId(MExecAsync* aController) 00070 : CISVAPIAsync(aController, KPhoneId), 00071 iPhoneIdV1Pckg(iPhoneIdV1) 00072 { 00073 // Empty method 00074 } 00075 00079 void CPhoneId::ConstructL() 00080 { 00081 // Empty method 00082 } 00083 00088 void CPhoneId::RunL() 00089 { 00090 // Print Phone Info 00091 if(iStatus != KErrNone) 00092 { 00093 iConsole->Printf(KError); 00094 00095 // Print the error status code 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 // Print phone manufacturer 00108 iConsole->Printf(manufacturer); 00109 iConsole->Printf(KNewLine); 00110 00111 // Print phone model 00112 iConsole->Printf(model); 00113 iConsole->Printf(KNewLine); 00114 00115 // Print the IMEI or ESN serial number 00116 iConsole->Printf(serialNumber); 00117 iConsole->Printf(KNewLine); 00118 00119 ExampleComplete(); 00120 } 00121 else 00122 { 00123 // Application isn't registered! 00124 00125 // Sim Tsy Config doesn't match Lits defined in CPhoneId 00126 // Could end Application here by calling Terminate(). 00127 // Wait for 5 seconds then continue by calling ExampleComplete(). 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 // Cancels an outstanding asynchronous request. 00142 iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel); 00143 } 00144 00151 TBool CPhoneId::AppRegistered() 00152 { 00153 // Values on phone 00154 TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer; 00155 TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel; 00156 TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber; 00157 00158 // Registered values 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 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.