examples/Telephony/ETel3rdPartyExample/PhoneMonitoring/CGetIndicator.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 #include "CGetIndicator.h"
00017 
00025 CGetIndicator* CGetIndicator::NewL(MExecAsync* aController)
00026         {
00027         CGetIndicator* self = new(ELeave) CGetIndicator(aController);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         CleanupStack::Pop(self);
00031         return self;
00032         }
00033 
00038 CGetIndicator::~CGetIndicator()
00039         {
00040         Cancel();
00041         }
00042 
00047 void CGetIndicator::DoStartRequestL()
00048         {
00049         _LIT(KDummyAnswerPanic, "CGetIndicator Get Method");
00050         __ASSERT_ALWAYS(!IsActive(), User::Panic(KDummyAnswerPanic, 1));
00051         iRequestNotify = EFalse;
00052         
00053         // Retrieves the battery charging indicator, the network availability indicator and call-in-progress indicator.
00054         iTelephony->GetIndicator(iStatus, iIndicatorV1Pckg);
00055         SetActive();
00056         }
00057 
00064 CGetIndicator::CGetIndicator(MExecAsync* aController)
00065         : CISVAPIAsync(aController, KGetIndicator),
00066           iIndicatorV1Pckg(iIndicatorV1)
00067         {
00068         // Empty method
00069         }
00070 
00074 void CGetIndicator::ConstructL()
00075         {
00076         // Empty method
00077         }
00078 
00083 void CGetIndicator::RunL()
00084         {
00085         // Print Indicator Info
00086         if(iStatus != KErrNone)
00087                 {
00088                 iConsole->Printf(KError);
00089                 
00090                 // Print the error status code
00091                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00092                 }
00093         else
00094                 {
00095       if(iIndicatorV1.iCapabilities & CTelephony::KIndChargerConnected)
00096                         {
00097                         // We can detect when a charger is connected
00098                         if(iIndicatorV1.iIndicator & CTelephony::KIndChargerConnected)
00099                                 {
00100                                 // Charger is connected
00101                                 iConsole->Printf(_L("Charger connected\n"));
00102                                 }
00103                                 else
00104                                 {
00105                                 // Charger is not connected
00106                                 iConsole->Printf(_L("Charger not connected\n"));
00107                                 }
00108                         }
00109                 else
00110                         {
00111                         // We do not know whether a charger is connected.
00112                         iConsole->Printf(_L("Status of charger unknown\n"));
00113                         }
00114                 if (iRequestNotify)
00115                 {
00116                 DoRequestNotificationL();
00117                 }
00118                 else
00119                 {
00120                         ExampleComplete();
00121                 }
00122                 }
00123         }
00124 
00128 void CGetIndicator::DoRequestNotificationL()
00129    {
00130         // Panic if this object is already performing an asynchronous operation.
00131         // Application will panic if you call SetActive() on an already active object.
00132         _LIT( KNotifyPanic, "CGetIndicator Notify Method" );
00133         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00134         iRequestNotify = ETrue;
00135         
00136         // Registers interest in receiving change notifications for events.
00137         iTelephony->NotifyChange(       iStatus,
00138                                                                 CTelephony::EIndicatorChange,
00139                                                                 iIndicatorV1Pckg );
00140         SetActive();
00141         }
00142 
00146 void CGetIndicator::DoCancel()
00147         {
00148         // Cancels an outstanding asynchronous request.
00149         iTelephony->CancelAsync(CTelephony::EIndicatorChangeCancel);
00150         }

Generated by  doxygen 1.6.2