|
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 |
|
17 #include "CCallBarringStatus.h" |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aController Pointer to MExecAsync object passed to constructor of |
|
23 CISVAPIBase |
|
24 @return Instance of CCallBarringStatus class |
|
25 */ |
|
26 CCallBarringStatus* CCallBarringStatus::NewL(MExecAsync* aController) |
|
27 { |
|
28 CCallBarringStatus* self = new(ELeave) CCallBarringStatus(aController); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 /** |
|
36 Destructor. |
|
37 Calls Cancel() to cancel outstanding requests. |
|
38 */ |
|
39 CCallBarringStatus::~CCallBarringStatus() |
|
40 { |
|
41 Cancel(); |
|
42 } |
|
43 |
|
44 /** |
|
45 Gets the current call barring status and stores result in |
|
46 iCallBarringStatusV1Pckg. |
|
47 */ |
|
48 void CCallBarringStatus::DoStartRequestL() |
|
49 { |
|
50 _LIT( KNotifyPanic, "CCallBarringStatus Get Method" ); |
|
51 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); |
|
52 iRequestNotify = EFalse; |
|
53 CTelephony::TCallBarringCondition condition = CTelephony::EBarAllIncoming; |
|
54 |
|
55 // Interrogate the current status of the call barring services. |
|
56 iTelephony->GetCallBarringStatus( iStatus, |
|
57 condition, |
|
58 iCallBarringStatusV1Pckg); |
|
59 SetActive(); |
|
60 } |
|
61 |
|
62 /** |
|
63 Constructor. |
|
64 |
|
65 @param aController Pointer to an MExecAsync object passed to constructor of |
|
66 CISVAPIBase. |
|
67 */ |
|
68 CCallBarringStatus::CCallBarringStatus(MExecAsync* aController) |
|
69 : CISVAPIAsync(aController, KCallBarringStatus), |
|
70 iCallBarringStatusV1Pckg(iCallBarringStatusV1) |
|
71 { |
|
72 // Empty method |
|
73 } |
|
74 |
|
75 /** |
|
76 Second phase constructor. |
|
77 */ |
|
78 void CCallBarringStatus::ConstructL() |
|
79 { |
|
80 // Empty method |
|
81 } |
|
82 |
|
83 /** |
|
84 Checks the status of the active object and displays the retrieved call barring |
|
85 status if there is no error. |
|
86 */ |
|
87 void CCallBarringStatus::RunL() |
|
88 { |
|
89 if(iStatus != KErrNone) |
|
90 { |
|
91 iConsole->Printf(KError); |
|
92 |
|
93 // Print the error status code |
|
94 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
95 } |
|
96 else |
|
97 { |
|
98 // Print the output to the console if there is no error. |
|
99 iConsole->Printf(KCallBarringStatusMsg); |
|
100 switch(iCallBarringStatusV1.iCallBarring) |
|
101 { |
|
102 case CTelephony::EStatusActive: |
|
103 iConsole->Printf(_L("Call barring status is active.\n")); |
|
104 break; |
|
105 case CTelephony::ENotActive: |
|
106 iConsole->Printf(_L("Call barring status is not active.\n")); |
|
107 break; |
|
108 case CTelephony::ENotProvisioned: |
|
109 iConsole->Printf(_L("Call barring status is not provisioned.\n")); |
|
110 break; |
|
111 case CTelephony::ENotAvailable: |
|
112 iConsole->Printf(_L("Call barring status is not available.\n")); |
|
113 break; |
|
114 case CTelephony::EUnknown: |
|
115 default: |
|
116 iConsole->Printf(_L("Call barring status is unknown.\n")); |
|
117 break; |
|
118 } |
|
119 } |
|
120 ExampleComplete(); |
|
121 } |
|
122 |
|
123 /** |
|
124 Cancels the asynchronous request to CTelephony::GetCallBarringStatus(). |
|
125 */ |
|
126 void CCallBarringStatus::DoCancel() |
|
127 { |
|
128 // Cancels an outstanding asynchronous request. |
|
129 iTelephony->CancelAsync(CTelephony::EGetCallBarringStatusCancel); |
|
130 } |
|
131 |