1 /* |
|
2 * Copyright (c) 2007 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: This is the header for the Diagnostics Network registration |
|
15 * status watcher. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef DIAGNETWORKREGSTATUSWATCHER_H |
|
21 #define DIAGNETWORKREGSTATUSWATCHER_H |
|
22 |
|
23 // Include files |
|
24 #include <e32base.h> // CActive |
|
25 #include <etel3rdparty.h> // CTelephony |
|
26 |
|
27 //Forward declaration |
|
28 class MDiagNetworkRegStatusObserver; |
|
29 |
|
30 |
|
31 /** |
|
32 * Diagnostics Network registration status watcher |
|
33 * |
|
34 * This class can be used as an observer for network status. After |
|
35 * instantiating the class and calling StartObserver(), the class firstly |
|
36 * informs the client of the current registration status and then goes into |
|
37 * an observing mode for any changes in the network registration status. |
|
38 * |
|
39 */ |
|
40 class CDiagNetworkRegStatusWatcher : public CActive |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Symbian OS constructor. |
|
46 * |
|
47 * @param aCallBack A reference to the callback for this network |
|
48 registration status watcher |
|
49 * @return An pointer to the new instance of CDiagNetworkRegStatusWatcher. |
|
50 */ |
|
51 IMPORT_C static CDiagNetworkRegStatusWatcher* NewL( |
|
52 MDiagNetworkRegStatusObserver& aCallBack ); |
|
53 |
|
54 /** |
|
55 * Default C++ virtual destructor |
|
56 */ |
|
57 IMPORT_C virtual ~CDiagNetworkRegStatusWatcher(); |
|
58 |
|
59 /** |
|
60 * This function is used by client to start the watcher. Firstly, the |
|
61 * watcher will inform the clients via call |
|
62 * MDiagNetworkRegStatusObserver::InitialNetworkRegistrationStatusL() |
|
63 * and then go into an observing mode for any changes in the network |
|
64 * registration status. The changes status is informed via |
|
65 * MDiagNetworkRegStatusObserver::NetworkRegistrationStatusChangeL() |
|
66 */ |
|
67 IMPORT_C void StartObserver(); |
|
68 |
|
69 |
|
70 /** |
|
71 * This function is used by client to stop the observer. |
|
72 */ |
|
73 IMPORT_C void StopObserver(); |
|
74 |
|
75 private: |
|
76 |
|
77 /** |
|
78 * C++ constructor. |
|
79 * |
|
80 * @param aCallBack A reference to the callback for Network |
|
81 * registration status observer |
|
82 */ |
|
83 CDiagNetworkRegStatusWatcher( MDiagNetworkRegStatusObserver& |
|
84 aCallBack ); |
|
85 |
|
86 /** |
|
87 * Symbian C++ 2nd phase constructor. |
|
88 * |
|
89 */ |
|
90 void ConstructL(); |
|
91 |
|
92 private: // From base class CActive |
|
93 |
|
94 /** |
|
95 * Handle active object completion event. |
|
96 */ |
|
97 virtual void RunL(); |
|
98 |
|
99 /** |
|
100 * Handle active object cancel event. |
|
101 */ |
|
102 virtual void DoCancel(); |
|
103 |
|
104 private: // private functions |
|
105 |
|
106 /** |
|
107 * Handler for the internal state EStateWaitForInitialStatus |
|
108 */ |
|
109 void HandleInitialStatusL(); |
|
110 |
|
111 /** |
|
112 * Handler for the internal state EStateWaitForStatusChange |
|
113 */ |
|
114 void HandleNetworkStatusChangeL(); |
|
115 |
|
116 /** |
|
117 * This function wraps the logic to decide if the device is currently |
|
118 * registered or not. |
|
119 * |
|
120 * @return ETrue if the devide is registered, EFalse if the device is |
|
121 * not registered. |
|
122 */ |
|
123 TBool IsDeviceRegisteredOnNetwork(); |
|
124 |
|
125 private: |
|
126 |
|
127 /** States of the Network registration status watcher */ |
|
128 enum TDiagNetwRegStatusWatcherState |
|
129 { |
|
130 EStateInit = 0, |
|
131 EStateWaitForInitialStatus, |
|
132 EStateWaitForStatusChange, |
|
133 EStateStopping |
|
134 }; |
|
135 |
|
136 /** variable to store the internal state of the network registration |
|
137 * status watcher |
|
138 */ |
|
139 TDiagNetwRegStatusWatcherState iState; |
|
140 |
|
141 /** Interface to phone's telephony system. Own. */ |
|
142 CTelephony* iTelephony; |
|
143 |
|
144 /** Defines the current network registration status */ |
|
145 CTelephony::TNetworkRegistrationV1 iRegV1; |
|
146 |
|
147 /** A typedef'd packaged CTelephony::TNetworkRegistrationV1 for |
|
148 passing through a generic API method. */ |
|
149 CTelephony::TNetworkRegistrationV1Pckg iRegV1Pckg; |
|
150 |
|
151 /** The callback interface for this instance of Network |
|
152 registration status observer */ |
|
153 MDiagNetworkRegStatusObserver& iCallBack; |
|
154 |
|
155 /** This variable remembers whether in previous state the |
|
156 * the device was registered or not |
|
157 */ |
|
158 TBool iPreviouslyRegistered; |
|
159 }; |
|
160 |
|
161 #endif // DIAGNETWORKREGSTATUSWATCHER_H |
|
162 |
|
163 //End of file |
|
164 |
|