|
1 /* |
|
2 * Copyright (c) 2010 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: Listen VPN toggle key changes in central repository. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef MPMVPNTOGGLEWATCHER_H |
|
19 #define MPMVPNTOGGLEWATCHER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 class CRepository; |
|
26 |
|
27 // Stop after this many consecutive central repository errors. |
|
28 const TInt KMpmVpnToggleWatcherCenRepErrorThreshold = 80; |
|
29 |
|
30 /** |
|
31 * Class that specifies the functions for handling notify messages about |
|
32 * VPN toggle key changes in central repository. |
|
33 */ |
|
34 class MMpmVpnToggleWatcherNotify |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Sets values for VPN toggle after VPN toggle key changes in central |
|
40 * repository. |
|
41 * @param aVpnPreferred Informs if VPN connection is preferred |
|
42 * connection |
|
43 * @param aVpnIapId VPN IAP Id, which is used for VPN connection, when |
|
44 * VPN connection is preferred |
|
45 * @param aSnapId SNAP Id SNAP Id, which is used for VPN connection, |
|
46 * when VPN connection is preferred |
|
47 */ |
|
48 virtual void SetVpnToggleValuesL( const TBool aVpnPreferred, |
|
49 const TUint32 aVpnIapId, |
|
50 const TUint32 aSnapId ) = 0; |
|
51 }; |
|
52 |
|
53 |
|
54 /** |
|
55 * Class for monitoring VPN toggle key changes in central repository. |
|
56 * Follows KMpmVpnToggleCenRepUid key in central repository. |
|
57 */ |
|
58 class CMpmVpnToggleWatcher : public CActive |
|
59 { |
|
60 public: |
|
61 |
|
62 /** |
|
63 * Two-phased constructor. |
|
64 * @param aNotify Handler for notify messages. |
|
65 */ |
|
66 static CMpmVpnToggleWatcher* NewL( MMpmVpnToggleWatcherNotify& aNotify ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 virtual ~CMpmVpnToggleWatcher(); |
|
72 |
|
73 /** |
|
74 * Call this when you want to start listen event. |
|
75 */ |
|
76 void StartL(); |
|
77 |
|
78 /** |
|
79 * Informs if VPN connection is preferred. |
|
80 * @return True if VPN connection is preferred. |
|
81 */ |
|
82 TBool IsVpnConnectionPreferred() const; |
|
83 |
|
84 /** |
|
85 * Returns VPN IAP Id, which is used for VPN connection, when VPN |
|
86 * connection is preferred. |
|
87 * @return VPN IAP Id |
|
88 */ |
|
89 TUint32 VpnIapId() const; |
|
90 |
|
91 /** |
|
92 * Returns SNAP Id, which is used for VPN connection, when VPN |
|
93 * connection is preferred. |
|
94 * @return SNAP Id |
|
95 */ |
|
96 TUint32 SnapId() const; |
|
97 |
|
98 /** |
|
99 * Resets VPN toggle values. |
|
100 */ |
|
101 void ResetVpnToggleValues(); |
|
102 |
|
103 private: |
|
104 |
|
105 CMpmVpnToggleWatcher( MMpmVpnToggleWatcherNotify& aNotify ); |
|
106 |
|
107 void ConstructL(); |
|
108 |
|
109 /** |
|
110 * Request for notifications. |
|
111 * @return Error value |
|
112 */ |
|
113 TInt RequestNotifications(); |
|
114 |
|
115 /** |
|
116 * Gets VPN toggle values. |
|
117 * @return Error value |
|
118 */ |
|
119 TInt GetVpnToggleValues(); |
|
120 |
|
121 // from base class CActive |
|
122 |
|
123 void RunL(); |
|
124 |
|
125 void DoCancel(); |
|
126 |
|
127 private: // data |
|
128 |
|
129 /** |
|
130 * Central repository handle |
|
131 * Own. |
|
132 */ |
|
133 CRepository* iRepository; |
|
134 |
|
135 /** |
|
136 * Informs if VPN connection is preferred connection |
|
137 * Own. |
|
138 */ |
|
139 TBool iVpnConnectionPreferred; |
|
140 |
|
141 /** |
|
142 * VPN IAP Id which is used, when VPN connection is preferred |
|
143 * Own. |
|
144 */ |
|
145 TUint32 iVpnIapId; |
|
146 |
|
147 /** |
|
148 * SNAP Id which is used, when VPN connection is preferred |
|
149 * Own. |
|
150 */ |
|
151 TUint32 iSnapId; |
|
152 |
|
153 /** |
|
154 * Error counter. |
|
155 */ |
|
156 TUint iErrorCounter; |
|
157 |
|
158 /** |
|
159 * Handler for notify messages. |
|
160 * Not own. |
|
161 */ |
|
162 MMpmVpnToggleWatcherNotify& iNotify; |
|
163 |
|
164 }; |
|
165 |
|
166 #endif // MPMVPNTOGGLEWATCHER_H |