examples/Telephony/ETel3rdPartyExample/PhoneMonitoring/CSignalInfo.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 "CSignalInfo.h"
00017 
00025 CSignalInfo* CSignalInfo::NewL(MExecAsync* aController)
00026         {
00027         CSignalInfo* self = new(ELeave) CSignalInfo(aController);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         CleanupStack::Pop(self);
00031         return self;
00032         }
00033 
00038 CSignalInfo::~CSignalInfo()
00039         {
00040         Cancel();
00041         }
00042 
00046 void CSignalInfo::DoStartRequestL()
00047         {
00048         _LIT(KDummyAnswerPanic, "CSignalInfo Get Method");
00049         __ASSERT_ALWAYS(!IsActive(), User::Panic(KDummyAnswerPanic, 1));
00050         iRequestNotify = EFalse;
00051         
00052         // Retrieves the phone's current signal strength via the aDes argument.
00053         iTelephony->GetSignalStrength(iStatus, iSignalStrengthV1Pckg);
00054         SetActive();
00055         }
00056 
00063 CSignalInfo::CSignalInfo(MExecAsync* aController)
00064         : CISVAPIAsync(aController, KSignalInfo),
00065           iSignalStrengthV1Pckg(iSignalStrengthV1)
00066         {
00067         // Empty method
00068         }
00069 
00073 void CSignalInfo::ConstructL()
00074         {
00075         // Empty method
00076         }
00077 
00082 void CSignalInfo::RunL()
00083         {
00084         if(iStatus != KErrNone)
00085                 {
00086                 iConsole->Printf(KError);
00087                 
00088                 // Print the error status code
00089                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00090                 }
00091         else
00092                 {
00093                 TInt32 strength = iSignalStrengthV1.iSignalStrength;
00094                 TInt8 bars = iSignalStrengthV1.iBar;
00095                 if (iRequestNotify)
00096                         {
00097                         iConsole->ClearScreen();
00098                         iConsole->Printf(_L("~*THIS IS A NOTIFICATION*~\n"));
00099                         }
00100                 iConsole->Printf(KSignalStrengthMsg);
00101                 iConsole->Printf(_L("There are %d bars!\n"), bars);
00102                 iConsole->Printf(_L("Signal Strength is %d!\n"), strength);
00103                 if (iRequestNotify)
00104                         {
00105                         DoRequestNotificationL();
00106                         }
00107                 else
00108                         {
00109                         ExampleComplete();
00110                         }
00111                 }
00112         }
00113 
00117 void CSignalInfo::DoRequestNotificationL()
00118    {
00119         // Panic if this object is already performing an asynchronous operation. 
00120         // Application will panic if you call SetActive() on an already active object.
00121         _LIT( KNotifyPanic, "CSignalInfo Notify Method" );
00122         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00123         iRequestNotify = ETrue;
00124         
00125         // Registers interest in receiving change notifications for events.
00126         iTelephony->NotifyChange(       iStatus,
00127                                                                 CTelephony::ESignalStrengthChange,
00128                                                                 iSignalStrengthV1Pckg );
00129         SetActive();
00130         }
00131 
00135 void CSignalInfo::DoCancel()
00136         {
00137         // Cancels an outstanding asynchronous request.
00138         iTelephony->CancelAsync(CTelephony::ESignalStrengthChangeCancel);
00139         }

Generated by  doxygen 1.6.2