|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CSIPSNAPAVAILABILITYMONITOR_H |
|
19 #define CSIPSNAPAVAILABILITYMONITOR_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "MSystemStateConnUsagePermissionObserver.h" |
|
23 #include <sipsystemstatemonitor.h> |
|
24 #include <rconnmon.h> |
|
25 #include <e32base.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MSipSystemStateObserver; |
|
29 |
|
30 // CLASS DEFINITION |
|
31 /** |
|
32 * A class for monitoring the availability of a SNAP. |
|
33 */ |
|
34 class CSipSnapAvailabilityMonitor : |
|
35 public CActive, |
|
36 public MConnectionMonitorObserver, |
|
37 public MSystemStateConnUsagePermissionObserver |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Static constructor |
|
43 * @param aSnapId the ID of the SNAP to be monitored |
|
44 * @param aPermissionToUseNetwork the current permission to use network |
|
45 * @param aObserver observer to be notified about SNAP availability |
|
46 * @return An initialized instance of this class. |
|
47 */ |
|
48 static CSipSnapAvailabilityMonitor* NewL( |
|
49 TUint32 aSnapId, |
|
50 TBool aPermissionToUseNetwork, |
|
51 MSipSystemStateObserver& aObserver ); |
|
52 |
|
53 /** |
|
54 * Static constructor |
|
55 * @param aSnapId the ID of the SNAP to be monitored |
|
56 * @param aPermissionToUseNetwork the current permission to use network |
|
57 * @param aObserver observer to be notified about SNAP availability |
|
58 * @return An initialized instance of this class. |
|
59 */ |
|
60 static CSipSnapAvailabilityMonitor* NewLC( |
|
61 TUint32 aSnapId, |
|
62 TBool aPermissionToUseNetwork, |
|
63 MSipSystemStateObserver& aObserver ); |
|
64 |
|
65 /// Destructor |
|
66 ~CSipSnapAvailabilityMonitor(); |
|
67 |
|
68 public: // From CActive |
|
69 |
|
70 void RunL(); |
|
71 |
|
72 void DoCancel(); |
|
73 |
|
74 public: // From MConnectionMonitorObserver |
|
75 |
|
76 void EventL( const CConnMonEventBase &aConnMonEvent ); |
|
77 |
|
78 public: // from MSystemStateConnUsagePermissionObserver |
|
79 |
|
80 void UsagePermissionChanged( TBool aPermissionToUse, TInt aError ); |
|
81 |
|
82 public: // New functions |
|
83 |
|
84 TUint32 SnapId() const; |
|
85 |
|
86 CSipSystemStateMonitor::TSnapAvailability SnapAvailability() const; |
|
87 |
|
88 void AddObserverL( MSipSystemStateObserver& aObserver ); |
|
89 |
|
90 void RemoveObserver( MSipSystemStateObserver& aObserver ); |
|
91 |
|
92 TBool HasObservers() const; |
|
93 |
|
94 private: // Constructors |
|
95 |
|
96 CSipSnapAvailabilityMonitor( |
|
97 TUint32 aSnapId, |
|
98 TBool aPermissionToUseNetwork ); |
|
99 |
|
100 void ConstructL( MSipSystemStateObserver& aObserver ); |
|
101 |
|
102 private: // Private methods |
|
103 |
|
104 TBool IsSnapAvailable( |
|
105 const TConnMonSNAPInfo& aSnapInfo, |
|
106 TUint32 aSnapId ) const; |
|
107 |
|
108 void NotifyObservers() const; |
|
109 |
|
110 TBool SetCurrentState( |
|
111 TBool aPermissionToUseNetwork, |
|
112 TBool aSnapAvailable ); |
|
113 |
|
114 TBool CanSnapBeUsed() const; |
|
115 |
|
116 private: // Data |
|
117 |
|
118 TUint32 iSnapId; |
|
119 TBool iPermissionToUseNetwork; |
|
120 TBool iSnapAvailable; |
|
121 // Observers not owned |
|
122 RPointerArray<MSipSystemStateObserver> iObservers; |
|
123 /// Connection monitor session. Owned. |
|
124 RConnectionMonitor iConnMon; |
|
125 TConnMonSNAPInfoBuf iSnapInfoBuf; |
|
126 // ETrue if successfully connected to Connection Monitor Server |
|
127 // (iConnMon). |
|
128 TBool iIsConnected; |
|
129 |
|
130 private: // For unit testing purposes |
|
131 |
|
132 friend class CSipSnapAvailabilityMonitorTest; |
|
133 }; |
|
134 |
|
135 #endif // CSIPSNAPAVAILABILITYMONITOR_H |