|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CLineStatus.h" |
|
17 #include <simtsy.h> |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aController Pointer to MExecAsync object passed to constructor of |
|
23 CISVAPIBase |
|
24 @return Instance of CLineStatus class |
|
25 */ |
|
26 CLineStatus* CLineStatus::NewL(MExecAsync* aController) |
|
27 { |
|
28 CLineStatus* self = new(ELeave) CLineStatus(aController); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 /** |
|
36 Destructor. |
|
37 Cancels outstanding requests. |
|
38 */ |
|
39 CLineStatus::~CLineStatus() |
|
40 { |
|
41 Cancel(); |
|
42 } |
|
43 |
|
44 /** |
|
45 Gets the line status of the voice line, stores the result in iLineStatusV1Pckg |
|
46 and displays the result to the console. |
|
47 */ |
|
48 void CLineStatus::DoStartRequestL() |
|
49 { |
|
50 iRequestNotify = EFalse; |
|
51 CTelephony::TPhoneLine line = CTelephony::EVoiceLine; |
|
52 |
|
53 // Retrieves the status of the line selected by the argument |
|
54 iTelephony->GetLineStatus(line, iLineStatusV1Pckg); |
|
55 CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus; |
|
56 switch (voiceLineStatus) |
|
57 { |
|
58 case CTelephony::EStatusRinging: |
|
59 iConsole->Printf(_L("RING RING RING\n")); |
|
60 break; |
|
61 case CTelephony::EStatusConnected: |
|
62 iConsole->Printf(_L("Line Status: Connected\n")); |
|
63 break; |
|
64 case CTelephony::EStatusConnecting: |
|
65 iConsole->Printf(_L("Line Status: Connecting\n")); |
|
66 break; |
|
67 case CTelephony::EStatusAnswering: |
|
68 iConsole->Printf(_L("Line Status: Answering\n")); |
|
69 break; |
|
70 case CTelephony::EStatusIdle: |
|
71 iConsole->Printf(_L("Line Status: Idle\n")); |
|
72 break; |
|
73 case CTelephony::EStatusDisconnecting: |
|
74 iConsole->Printf(_L("Line Status: Disconnecting\n")); |
|
75 break; |
|
76 default: |
|
77 iConsole->Printf(_L("Line status changed.\n")); |
|
78 break; |
|
79 } |
|
80 if (voiceLineStatus == CTelephony::EStatusRinging) |
|
81 { |
|
82 ExampleNotify(); |
|
83 } |
|
84 else |
|
85 { |
|
86 ExampleComplete(); |
|
87 } |
|
88 } |
|
89 |
|
90 /** |
|
91 Default constructor. |
|
92 |
|
93 @param aController Pointer to an MExecAsync object passed to constructor of |
|
94 CISVAPIBase |
|
95 */ |
|
96 CLineStatus::CLineStatus(MExecAsync* aController) |
|
97 : CISVAPIAsync(aController, KLineStatus), |
|
98 iLineStatusV1Pckg(iLineStatusV1) |
|
99 { |
|
100 // Empty method |
|
101 } |
|
102 |
|
103 /** |
|
104 Second phase constructor. |
|
105 */ |
|
106 void CLineStatus::ConstructL() |
|
107 { |
|
108 // Empty method |
|
109 } |
|
110 |
|
111 /** |
|
112 Checks the status of the active object and prints the voice line status to the |
|
113 console if there is no error. |
|
114 */ |
|
115 void CLineStatus::RunL() |
|
116 { |
|
117 CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus; |
|
118 if(iStatus != KErrNone) |
|
119 { |
|
120 iConsole->Printf(KError); |
|
121 |
|
122 // Print the error status code |
|
123 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
124 } |
|
125 else |
|
126 { |
|
127 switch (voiceLineStatus) |
|
128 { |
|
129 case CTelephony::EStatusRinging: |
|
130 iConsole->Printf(_L("RING RING RING\n")); |
|
131 break; |
|
132 case CTelephony::EStatusConnected: |
|
133 iConsole->Printf(_L("Line Status: Connected\n")); |
|
134 break; |
|
135 case CTelephony::EStatusConnecting: |
|
136 iConsole->Printf(_L("Line Status: Connecting\n")); |
|
137 break; |
|
138 case CTelephony::EStatusAnswering: |
|
139 iConsole->Printf(_L("Line Status: Answering\n")); |
|
140 break; |
|
141 case CTelephony::EStatusIdle: |
|
142 iConsole->Printf(_L("Line Status: Idle\n")); |
|
143 break; |
|
144 case CTelephony::EStatusDisconnecting: |
|
145 iConsole->Printf(_L("Line Status: Disconnecting\n")); |
|
146 break; |
|
147 default: |
|
148 iConsole->Printf(_L("Line status changed.\n")); |
|
149 break; |
|
150 } |
|
151 if (voiceLineStatus == CTelephony::EStatusRinging) |
|
152 { |
|
153 ExampleNotify(); |
|
154 } |
|
155 else |
|
156 { |
|
157 RequestNotificationL(); |
|
158 } |
|
159 } |
|
160 } |
|
161 |
|
162 /** |
|
163 Requests to receive notifications of change in the voice line status. |
|
164 */ |
|
165 void CLineStatus::DoRequestNotificationL() |
|
166 { |
|
167 // Panic if this object is already performing an asynchronous operation. |
|
168 // Application will panic if you call SetActive() on an already active object. |
|
169 _LIT( KNotifyPanic, "CLineStatus Notify Method" ); |
|
170 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); |
|
171 iRequestNotify = ETrue; |
|
172 |
|
173 // Registers interest in receiving change notifications for events. |
|
174 iTelephony->NotifyChange( iStatus, |
|
175 CTelephony::EVoiceLineStatusChange, |
|
176 iLineStatusV1Pckg ); |
|
177 SetActive(); |
|
178 } |
|
179 |
|
180 /** |
|
181 Cancel asynchronous request to CTelephony::GetLineStatus() |
|
182 */ |
|
183 void CLineStatus::DoCancel() |
|
184 { |
|
185 // Cancels an outstanding asynchronous request. |
|
186 iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel); |
|
187 } |