|
1 // Copyright (c) 2008-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 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef SYMBIAN_PDPTIERMANAGER_H |
|
22 #define SYMBIAN_PDPTIERMANAGER_H |
|
23 |
|
24 #include <comms-infras/coretiermanager.h> |
|
25 #include <comms-infras/contentionmanager.h> |
|
26 #include <etelpckt.h> |
|
27 using namespace ESock; |
|
28 |
|
29 class CMBMSEngine; |
|
30 class CContextStatusMonitor; |
|
31 class CContextTypeChecker; |
|
32 |
|
33 |
|
34 class MPacketServiceNotifier |
|
35 { |
|
36 public: |
|
37 virtual void PacketServiceAttachedCallbackL() = 0; |
|
38 }; |
|
39 |
|
40 class MContextEventsObserver |
|
41 { |
|
42 public: |
|
43 virtual void PrimaryContextAddedL(const TName* aContextName) = 0; |
|
44 virtual void SecondaryContextAdded(const TName* aContextName) = 0; |
|
45 virtual void PrimaryContextDeleted(const CContextStatusMonitor* aContextStatusMonitor) = 0; |
|
46 virtual void ContextMonitoringError(const CContextStatusMonitor* aContextStatusMonitor, TInt aError) = 0; |
|
47 virtual void ContextTypeCheckingError(const TName* aContextName, TInt aError) = 0; |
|
48 }; |
|
49 |
|
50 class CContextStatusMonitor : public CActive |
|
51 { |
|
52 public: |
|
53 CContextStatusMonitor(RPacketService& aPacketService, MContextEventsObserver& aCallback); |
|
54 ~CContextStatusMonitor(); |
|
55 |
|
56 public: |
|
57 TBool StartL(const TName& aContextName); |
|
58 inline TBool IsPassedThroughActiveState() const; |
|
59 |
|
60 private: |
|
61 void RunL(); |
|
62 void DoCancel(); |
|
63 TInt RunError(TInt aError); |
|
64 |
|
65 private: |
|
66 RPacketService& iPacketService; |
|
67 RPacketContext iPacketContext; |
|
68 RPacketContext::TContextStatus iContextStatus; |
|
69 MContextEventsObserver& iCallback; |
|
70 TName iContextName; |
|
71 TBool iWasActive; |
|
72 }; |
|
73 |
|
74 |
|
75 class CPrimaryContextsMonitor : public CActive, MContextEventsObserver |
|
76 { |
|
77 enum TState {EEnumeratingContexts, EGettingInfo, EListening}; |
|
78 public: |
|
79 CPrimaryContextsMonitor(RPacketService& aPacketService, MContentionObserver& aCallback); |
|
80 ~CPrimaryContextsMonitor(); |
|
81 public: |
|
82 void StartL(); |
|
83 |
|
84 // from MContextEventsObserver |
|
85 void PrimaryContextAddedL(const TName* aContextName); |
|
86 void SecondaryContextAdded(const TName* aContextName); |
|
87 void PrimaryContextDeleted(const CContextStatusMonitor* aContextStatusMonitor); |
|
88 void ContextMonitoringError(const CContextStatusMonitor* aContextStatusMonitor, TInt aError); |
|
89 void ContextTypeCheckingError(const TName* aContextName, TInt aError); |
|
90 |
|
91 private: |
|
92 void RunL(); |
|
93 void DoCancel(); |
|
94 TInt RunError(TInt aError); |
|
95 void DeleteContextStatusMonitor(const CContextStatusMonitor* aContextStatusMonitor); |
|
96 void SwitchStateL(); |
|
97 void StartContextStatusMonitoringL(const TName& aContextName); |
|
98 void RemoveContextNameAndCheckNext(const TName* aContextName); |
|
99 void ProcessError(TInt aError); |
|
100 |
|
101 private: |
|
102 RPointerArray<CContextStatusMonitor> iContextMonitors; |
|
103 RPointerArray<TName> iAddedContextsNames; |
|
104 CContextTypeChecker* iContextTypeChecker; |
|
105 RPacketService& iPacketService; |
|
106 TState iState; |
|
107 RPacketService::TNifInfoV2 iCurrentNifInfo; |
|
108 TInt iInitialNifsCount; |
|
109 TInt iCurrentNifIndex; |
|
110 TBool iFirstContextAdded; |
|
111 MContentionObserver& iCallback; |
|
112 }; |
|
113 |
|
114 class CContextTypeChecker : public CActive |
|
115 { |
|
116 public: |
|
117 CContextTypeChecker(RPacketService& aPacketService, MContextEventsObserver& aCallback); |
|
118 ~CContextTypeChecker(); |
|
119 |
|
120 public: |
|
121 void Start(const TName* aContextName); |
|
122 void RunL(); |
|
123 TInt RunError(TInt aError); |
|
124 void DoCancel(); |
|
125 |
|
126 private: |
|
127 RPacketService& iPacketService; |
|
128 const TName* iContextName; |
|
129 MContextEventsObserver& iCallback; |
|
130 TInt iCountInNif; |
|
131 }; |
|
132 |
|
133 class CPdpContentionManager : public CContentionManager |
|
134 { |
|
135 public: |
|
136 static CPdpContentionManager* NewL(const ESock::CTierManagerBase& aTierManager, RPacketService& aPacketService); |
|
137 ~CPdpContentionManager(); |
|
138 |
|
139 public: |
|
140 void StartMonitoringL(); |
|
141 |
|
142 private: |
|
143 void ConstructL(RPacketService& aPacketService); |
|
144 CPdpContentionManager(const ESock::CTierManagerBase& aTierManager); |
|
145 |
|
146 private: |
|
147 // from CContentionManager |
|
148 virtual void ContentionResolved(const TContentionRequestItem& aContentionRequest, TBool aResult); |
|
149 virtual void ContentionOccured(ESock::CMetaConnectionProviderBase& aMcpr); |
|
150 virtual void ReportContentionAvailabilityStatus(ESock::CMetaConnectionProviderBase& aMcpr, const ESock::TAvailabilityStatus& aStatus) const; |
|
151 |
|
152 private: |
|
153 CPrimaryContextsMonitor* iPrimaryContextsMonitor; |
|
154 }; |
|
155 |
|
156 //PDP Tier Manager |
|
157 class CPDPTierManager : public CCoreTierManager, public MPacketServiceNotifier |
|
158 { |
|
159 public: |
|
160 static CPDPTierManager* NewL(ESock::CTierManagerFactoryBase& aFactory); |
|
161 ~CPDPTierManager(); |
|
162 |
|
163 public: |
|
164 void PacketServiceAttachedCallbackL(); |
|
165 TBool IsUnavailableDueToContention(const ESock::CMetaConnectionProviderBase* aMetaConnectionProvider) const; |
|
166 |
|
167 protected: |
|
168 CPDPTierManager(ESock::CTierManagerFactoryBase& aFactory, const MeshMachine::TNodeActivityMap& aActivityMap); |
|
169 |
|
170 virtual ESock::MProviderSelector* DoCreateProviderSelectorL(const Meta::SMetaData& aSelectionPreferences); |
|
171 virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
|
172 |
|
173 TBool HandleContentionL(ESock::CMetaConnectionProviderBase* aMcpr, Messages::TNodeId& aPendingCprId, TUint aPriority); |
|
174 private: |
|
175 void ConstructL(); |
|
176 |
|
177 private: |
|
178 CMBMSEngine* iMBMSEngine; |
|
179 CPdpContentionManager* iPdpContentionManager; |
|
180 }; |
|
181 |
|
182 inline TBool CContextStatusMonitor::IsPassedThroughActiveState() const |
|
183 { |
|
184 return iWasActive; |
|
185 } |
|
186 |
|
187 #endif // SYMBIAN_PDPTIERMANAGER_H |
|
188 |