telephonyutils/etel3rdpartyapi/ExampleApps/PhoneId/CPhoneId.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include "CPhoneId.h"
       
    18 
       
    19 /**
       
    20 Factory constructor.
       
    21 
       
    22 @param  aController Pointer to MExecAsync object passed to constructor of 
       
    23                     CISVAPIBase
       
    24 @return             Instance of CPhoneId class
       
    25 */
       
    26 CPhoneId* CPhoneId::NewL(MExecSync* aController)
       
    27 	{
       
    28 	CPhoneId* self = new(ELeave) CPhoneId(aController);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 /**
       
    36 Destructor.
       
    37 Cancels outstanding requests
       
    38 */
       
    39 CPhoneId::~CPhoneId()
       
    40 	{
       
    41 	Cancel();
       
    42 	}
       
    43 
       
    44 /**
       
    45 Gets the phone ID by calling 3rd party API function CTelephony::GetPhoneId().
       
    46 */
       
    47 void CPhoneId::DoStartRequestL()
       
    48 	{
       
    49 	// Retrieves the model information and unique identification of the mobile device.
       
    50 	iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
       
    51 	SetActive();
       
    52 	}
       
    53 
       
    54 /**
       
    55 Default constructor.
       
    56 
       
    57 @param aController Pointer to MExecAsync object passed to constructor of 
       
    58                    CISVAPIBase
       
    59 */
       
    60 CPhoneId::CPhoneId(MExecSync* aController)
       
    61 	: CISVAPISync(aController, KPhoneId),
       
    62 	  iPhoneIdV1Pckg(iPhoneIdV1)
       
    63 	{
       
    64 	// Empty method
       
    65 	}
       
    66 
       
    67 /**
       
    68 Second phase constructor.
       
    69 */
       
    70 void CPhoneId::ConstructL()
       
    71 	{
       
    72 	// Empty method
       
    73 	}
       
    74 
       
    75 /**
       
    76 Prints phone information to the console.
       
    77 */
       
    78 void CPhoneId::RunL()
       
    79 	{
       
    80 	if(iStatus != KErrNone)
       
    81 		{
       
    82 		iConsole->Printf(KError);
       
    83 		
       
    84 		// Print the status error code
       
    85 		iConsole->Printf(_L("%d\n"), iStatus.Int());
       
    86 		}
       
    87 	else
       
    88 		{
       
    89 		// Active object completed with no error, therefore print phone
       
    90 		// information to the console.
       
    91 		TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer = iPhoneIdV1.iManufacturer;
       
    92 		TBuf<CTelephony::KPhoneModelIdSize> model = iPhoneIdV1.iModel;
       
    93 		TBuf<CTelephony::KPhoneSerialNumberSize> serialNumber = iPhoneIdV1.iSerialNumber;
       
    94 		iConsole->Printf(KPhoneIdMsg);
       
    95 		
       
    96 		// Print phone manufacturer
       
    97 		iConsole->Printf(manufacturer);
       
    98 		iConsole->Printf(KNewLine);
       
    99 		
       
   100 		// Print phone model
       
   101 		iConsole->Printf(model);
       
   102 		iConsole->Printf(KNewLine);
       
   103 		
       
   104 		// Print the IMEI or ESN serial number
       
   105 		iConsole->Printf(serialNumber);
       
   106 		iConsole->Printf(KNewLine);
       
   107 		ExampleComplete();
       
   108 		}
       
   109 	}
       
   110 
       
   111 /**
       
   112 Cancels asynchronous request to CTelephony::GetPhoneId().
       
   113 */
       
   114 void CPhoneId::DoCancel()
       
   115 	{
       
   116 	// Cancels an outstanding asynchronous request.
       
   117 	iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
       
   118 	}