examples/Telephony/ETel3rdPartyExample/IncomingCalls/CDummyAnswer.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 "CDummyAnswer.h"
00017 #include "CMainMenu.h"
00018 
00025 CDummyAnswer* CDummyAnswer::NewL(MExecAsync* aController)
00026         {
00027         CDummyAnswer* self = new(ELeave) CDummyAnswer(aController);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         CleanupStack::Pop(self);
00031         return self;
00032         }
00033 
00039 CDummyAnswer::CDummyAnswer(MExecAsync* aController)
00040         : CActive(EPriorityStandard),
00041           iController(aController)
00042         {
00043         iConsole = iController->GConsole();
00044         CActiveScheduler::Add(this);
00045         }
00046 
00050 void CDummyAnswer::ExampleComplete()
00051         {
00052         iController->ExecComplete(KNotType);
00053         }
00054 
00058 void CDummyAnswer::ConstructL()
00059         {
00060         // Creates a thread-relative timer
00061         User::LeaveIfError(iTimer.CreateLocal());
00062         iFirstTime = ETrue;
00063         }
00064 
00068 void CDummyAnswer::ResetFirstTime()
00069         {
00070         iFirstTime = ETrue;
00071         }
00072 
00077 CDummyAnswer::~CDummyAnswer()
00078         {
00079         Cancel();
00080         iTimer.Close();
00081         }
00082 
00086 void CDummyAnswer::StartCount(TTimeIntervalMicroSeconds32 aDelay)
00087         {
00088         _LIT(KDummyAnswerPanic, "CDummyAnswer");
00089         __ASSERT_ALWAYS(!IsActive(), User::Panic(KDummyAnswerPanic, 1));
00090         iTimer.After(iStatus, aDelay);
00091         SetActive();
00092         }
00093 
00098 void CDummyAnswer::RunL()
00099         {
00100         if (iStatus != KErrNone)
00101                 {
00102                 iConsole->Printf(KError);
00103                 
00104                 // Print the error status code
00105                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00106                 }
00107         else
00108                 {
00109                 // Print console output message if there is no error
00110                 iConsole->ClearScreen();
00111                 iConsole->Printf(KMenuMsg);
00112                 iConsole->Printf(KHangupMsg);
00113                 iConsole->Printf(_L("Call Duration %d seconds\n"), iCount);
00114                 iCount++;
00115                 StartCount(1000000);
00116                 }
00117         if (iFirstTime)
00118                 {
00119                 iFirstTime = EFalse;
00120                 ExampleComplete();
00121                 }
00122         }
00123 
00127 void CDummyAnswer::DoCancel()
00128         {
00129         ResetFirstTime();
00130         iCount = 0;
00131         iTimer.Cancel();
00132         }

Generated by  doxygen 1.6.2