examples/Telephony/ETel3rdPartyExample/PhoneId/CPhoneId.cpp

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 //
00015 
00016 
00017 #include "CPhoneId.h"
00018 
00026 CPhoneId* CPhoneId::NewL(MExecSync* aController)
00027         {
00028         CPhoneId* self = new(ELeave) CPhoneId(aController);
00029         CleanupStack::PushL(self);
00030         self->ConstructL();
00031         CleanupStack::Pop(self);
00032         return self;
00033         }
00034 
00039 CPhoneId::~CPhoneId()
00040         {
00041         Cancel();
00042         }
00043 
00047 void CPhoneId::DoStartRequestL()
00048         {
00049         // Retrieves the model information and unique identification of the mobile device.
00050         iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
00051         SetActive();
00052         }
00053 
00060 CPhoneId::CPhoneId(MExecSync* aController)
00061         : CISVAPISync(aController, KPhoneId),
00062           iPhoneIdV1Pckg(iPhoneIdV1)
00063         {
00064         // Empty method
00065         }
00066 
00070 void CPhoneId::ConstructL()
00071         {
00072         // Empty method
00073         }
00074 
00078 void CPhoneId::RunL()
00079         {
00080         if(iStatus != KErrNone)
00081                 {
00082                 iConsole->Printf(KError);
00083                 
00084                 // Print the status error code
00085                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00086                 }
00087         else
00088                 {
00089                 // Active object completed with no error, therefore print phone
00090                 // information to the console.
00091                 TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer;
00092                 TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel;
00093                 TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber;
00094                 iConsole->Printf(KPhoneIdMsg);
00095                 
00096                 // Print phone manufacturer
00097                 iConsole->Printf(manufacturer);
00098                 iConsole->Printf(KNewLine);
00099                 
00100                 // Print phone model
00101                 iConsole->Printf(model);
00102                 iConsole->Printf(KNewLine);
00103                 
00104                 // Print the IMEI or ESN serial number
00105                 iConsole->Printf(serialNumber);
00106                 iConsole->Printf(KNewLine);
00107                 ExampleComplete();
00108                 }
00109         }
00110 
00114 void CPhoneId::DoCancel()
00115         {
00116         // Cancels an outstanding asynchronous request.
00117         iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
00118         }

Generated by  doxygen 1.6.2