|
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 "CFlightModeInfo.h" |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aController Pointer to MExecAsync object passed to constructor of |
|
23 CISVAPIBase |
|
24 @return Instance of CFlightModeInfo class |
|
25 */ |
|
26 CFlightModeInfo* CFlightModeInfo::NewL(MExecAsync* aController) |
|
27 { |
|
28 CFlightModeInfo* self = new(ELeave) CFlightModeInfo(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 CFlightModeInfo::~CFlightModeInfo() |
|
40 { |
|
41 Cancel(); |
|
42 } |
|
43 |
|
44 /** |
|
45 Gets the flight mode status and stores it in the iFlightModeV1Pckg. |
|
46 */ |
|
47 void CFlightModeInfo::DoStartRequestL() |
|
48 { |
|
49 // Retrieves the current flight mode status. |
|
50 iTelephony->GetFlightMode(iStatus, iFlightModeV1Pckg); |
|
51 SetActive(); |
|
52 } |
|
53 |
|
54 /** |
|
55 Constructor called by the CFlightModeInfo::NewL() factory constructor. |
|
56 |
|
57 @param aController Pointer to an MExecAsync object passed to constructor of |
|
58 CISVAPIBase |
|
59 */ |
|
60 CFlightModeInfo::CFlightModeInfo(MExecAsync* aController) |
|
61 : CISVAPIAsync(aController, KFlightModeInfo), |
|
62 iFlightModeV1Pckg(iFlightModeV1) |
|
63 { |
|
64 // Empty method |
|
65 } |
|
66 |
|
67 /** |
|
68 Second phase constructor. |
|
69 */ |
|
70 void CFlightModeInfo::ConstructL() |
|
71 { |
|
72 // Empty method |
|
73 } |
|
74 |
|
75 /** |
|
76 Displays the flight mode status if the active object completed with no error. |
|
77 */ |
|
78 void CFlightModeInfo::RunL() |
|
79 { |
|
80 if(iStatus != KErrNone) |
|
81 { |
|
82 iConsole->Printf(KError); |
|
83 |
|
84 // Print the error status code |
|
85 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
86 } |
|
87 else |
|
88 { |
|
89 switch (iFlightModeV1.iFlightModeStatus) |
|
90 { |
|
91 case CTelephony::EFlightModeOff: |
|
92 iConsole->Printf(_L("Flight Status is Off, you can make a call!\n")); |
|
93 ExampleComplete(); |
|
94 break; |
|
95 case CTelephony::EFlightModeOn: |
|
96 iConsole->Printf(_L("Flight Status is On, you can't make a call!\n")); |
|
97 User::After(5000000); |
|
98 AppTerminate(); |
|
99 break; |
|
100 } |
|
101 } |
|
102 } |
|
103 |
|
104 /** |
|
105 Requests to receive notifications of change in the flight mode. |
|
106 */ |
|
107 void CFlightModeInfo::DoRequestNotificationL() |
|
108 { |
|
109 // Panic if this object is already performing an asynchronous operation. |
|
110 // Application will panic if you call SetActive() on an already active object. |
|
111 _LIT( KNotifyPanic, "CFlightModeInfo Notify Method" ); |
|
112 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); |
|
113 iRequestNotify = ETrue; |
|
114 |
|
115 // Registers interest in receiving change notifications for events |
|
116 iTelephony->NotifyChange( iStatus, |
|
117 CTelephony::EFlightModeChange, |
|
118 iFlightModeV1Pckg ); |
|
119 SetActive(); |
|
120 } |
|
121 |
|
122 /** |
|
123 Cancels asynchronous request to CTelephony::GetFlightMode() |
|
124 */ |
|
125 void CFlightModeInfo::DoCancel() |
|
126 { |
|
127 // Cancels an outstanding asynchronous request. |
|
128 iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel); |
|
129 } |