|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Telephone call handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "shwslideshowtelephonehandler.h" |
|
21 #include "shwslideshowengine.h" |
|
22 #include "shwslideshowpausehandler.h" |
|
23 |
|
24 #include <glxlog.h> |
|
25 #include <glxtracer.h> |
|
26 // ----------------------------------------------------------------------------- |
|
27 // Constructor |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CShwTelephoneHandler* CShwTelephoneHandler::NewL( |
|
31 CShwSlideshowEngine& aEngine, |
|
32 CShwSlideShowPauseHandler& aPauseHandler ) |
|
33 { |
|
34 TRACER("CShwTelephoneHandler::NewL"); |
|
35 GLX_LOG_INFO( "CShwTelephoneHandler::NewL" ); |
|
36 CShwTelephoneHandler* self = |
|
37 new( ELeave) CShwTelephoneHandler( aEngine, aPauseHandler ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Destructor |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CShwTelephoneHandler::~CShwTelephoneHandler() |
|
49 { |
|
50 TRACER("CShwTelephoneHandler::~CShwTelephoneHandler"); |
|
51 GLX_LOG_INFO( "CShwTelephoneHandler::~CShwTelephoneHandler" ); |
|
52 Cancel(); |
|
53 delete iTelephony; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // StartL |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CShwTelephoneHandler::StartL() |
|
61 { |
|
62 TRACER("CShwTelephoneHandler::StartL"); |
|
63 GLX_LOG_INFO( "CShwTelephoneHandler::StartL" ); |
|
64 if ( !IsActive() ) |
|
65 { |
|
66 // request notification of change in status of the voice line |
|
67 iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, |
|
68 iLineStatusPckg ); |
|
69 // get on with it |
|
70 SetActive(); |
|
71 } |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // Constructor |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CShwTelephoneHandler::CShwTelephoneHandler( |
|
79 CShwSlideshowEngine& aEngine, |
|
80 CShwSlideShowPauseHandler& aPauseHandler ) |
|
81 : CActive( CActive::EPriorityStandard ), |
|
82 iEngine( aEngine ), |
|
83 iPauseHandler( aPauseHandler ), |
|
84 iLineStatusPckg( iLineStatus ) |
|
85 { |
|
86 TRACER("CShwTelephoneHandler::CShwTelephoneHandler"); |
|
87 GLX_LOG_INFO( "CShwTelephoneHandler::CShwTelephoneHandler" ); |
|
88 CActiveScheduler::Add( this ); |
|
89 // set initial line status |
|
90 iLineStatus.iStatus = CTelephony::EStatusUnknown; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // ConstructL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CShwTelephoneHandler::ConstructL() |
|
98 { |
|
99 TRACER("CShwTelephoneHandler::ConstructL"); |
|
100 GLX_LOG_INFO( "CShwTelephoneHandler::ConstructL" ); |
|
101 iTelephony = CTelephony::NewL(); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // RunL |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CShwTelephoneHandler::RunL() |
|
109 { |
|
110 TRACER("CShwTelephoneHandler::RunL"); |
|
111 GLX_LOG_INFO1( "CShwTelephoneHandler::RunL, status = %d", iStatus.Int() ); |
|
112 |
|
113 if( iStatus == KErrNone ) |
|
114 { |
|
115 // No error |
|
116 GLX_LOG_INFO1( "Line status = %d", iLineStatus.iStatus ); |
|
117 // Check the line's status |
|
118 if ( iLineStatus.iStatus == CTelephony::EStatusAnswering || |
|
119 iLineStatus.iStatus == CTelephony::EStatusConnecting || |
|
120 iLineStatus.iStatus == CTelephony::EStatusConnected ) |
|
121 { |
|
122 iPauseHandler.PhoneCallStartedL(); |
|
123 } |
|
124 else if ( iLineStatus.iStatus == CTelephony::EStatusIdle ) |
|
125 { |
|
126 iPauseHandler.PhoneCallEndedL(); |
|
127 } |
|
128 |
|
129 // reissue request for notification |
|
130 iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, |
|
131 iLineStatusPckg ); |
|
132 SetActive(); |
|
133 } |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // DoCancel |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CShwTelephoneHandler::DoCancel() |
|
141 { |
|
142 TRACER("CShwTelephoneHandler::DoCancel"); |
|
143 GLX_LOG_INFO( "CShwTelephoneHandler::DoCancel" ); |
|
144 // Cancel the voice line status requests |
|
145 if ( iTelephony ) |
|
146 { |
|
147 // The return code is ignored as there's no way of reporting it. |
|
148 iTelephony->CancelAsync( CTelephony::EVoiceLineStatusChangeCancel ); |
|
149 } |
|
150 } |
|
151 // End of file |