internetradio2.0/sessionlogsrc/irphoneinfo.cpp
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "irphoneinfo.h"
       
    20 #include "mirphoneinfoobserver.h"
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // Function: NewL
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 CPhoneInfo* CPhoneInfo::NewL(MIRPhoneInfoObserver* aObserver)
       
    27     {
       
    28     CPhoneInfo* self = new(ELeave) CPhoneInfo(aObserver);
       
    29     CleanupStack::PushL(self);
       
    30     self->ConstructL();
       
    31     CleanupStack::Pop(self);
       
    32     return self;
       
    33     }
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // Function: ~CPhoneInfo
       
    37 // default destructor
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CPhoneInfo::~CPhoneInfo()
       
    41     {
       
    42     Cancel();
       
    43     delete iTelephony;
       
    44     iTelephony = NULL;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Function: StartUpdatingL
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 void CPhoneInfo::StartUpdating()
       
    52     {
       
    53     // Retrieves the model information and unique identification of the mobile device.
       
    54     if(!IsActive() && iTelephony)
       
    55         {    
       
    56         iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
       
    57         SetActive();
       
    58         }
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Function: CPhoneInfo
       
    63 // default constructor
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CPhoneInfo::CPhoneInfo(MIRPhoneInfoObserver* aObserver)
       
    67     : CActive(EPriorityLow),
       
    68       iPhoneIdV1Pckg(iPhoneIdV1),
       
    69       iTelephony(NULL),
       
    70       iObserver(aObserver)
       
    71     {
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Function: ConstructL
       
    76 // Two phase constructor
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CPhoneInfo::ConstructL()
       
    80     {
       
    81     iTelephony = CTelephony::NewL();
       
    82     CActiveScheduler::Add(this);
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // Function: RunL
       
    87 // From CActive
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CPhoneInfo::RunL()
       
    91     {
       
    92     if(NULL != iObserver)
       
    93         {
       
    94         if(KErrNone == iStatus.Int())
       
    95             {
       
    96             TRAP_IGNORE(iObserver->ImeiUpdatedL(iPhoneIdV1.iSerialNumber));
       
    97             }
       
    98         else
       
    99             {
       
   100             TRAP_IGNORE(iObserver->ImeiUpdatedL(KNullDesC));
       
   101             }
       
   102         }
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Function: DoCancel
       
   107 // From CActive
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void CPhoneInfo::DoCancel()
       
   111     {
       
   112     // Cancels an outstanding asynchronous request.
       
   113     if(IsActive() && iTelephony)
       
   114         {    
       
   115         iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
       
   116         }
       
   117     }