|
1 // Copyright (c) 2006-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 |
|
18 /** |
|
19 @internalComponent |
|
20 */ |
|
21 #ifndef __NEGOTIATION_H__ |
|
22 #define __NEGOTIATION_H__ |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 |
|
27 #include "module_if.h" // ..MQoSNegotiateEvent is used as a base class of CNegotiateItem |
|
28 #include "qosparameters.h" // ..TQoSParameters is a member variable! |
|
29 #include "pfqoslib.h" // ..TPfqosMessage is a member variable! |
|
30 |
|
31 class CNegotiateItem; |
|
32 class CInternalQoSChannel; |
|
33 class RModule; |
|
34 class MQoSNegotiateEvent; |
|
35 class CFlowHook; |
|
36 class TExtensionData; |
|
37 |
|
38 // Base class for QoS sessions |
|
39 class CQoSSessionBase : public CBase |
|
40 { |
|
41 public: |
|
42 CQoSSessionBase(CFlowHook& aHook, TInt aChannelId); |
|
43 ~CQoSSessionBase(); |
|
44 virtual void Run(); |
|
45 virtual void SubRequestComplete(TInt aEvent, const TQoSParameters* aParams, const TExtensionData& aExtension, CNegotiateItem* aItem); |
|
46 |
|
47 protected: |
|
48 void DeliverEvent(TUint16 aEvent); |
|
49 void FatalError(TInt aErrorCode); |
|
50 CInternalQoSChannel* Channel() const; |
|
51 |
|
52 virtual TInt DoCall(RModule &aModule, MQoSNegotiateEvent& aCallback) = 0; |
|
53 virtual void RequestComplete() = 0; |
|
54 private: |
|
55 void Proceed(); |
|
56 |
|
57 protected: |
|
58 CFlowHook& iHook; // Flow hook owner of this session |
|
59 RPointerArray<RModule>& iModuleList; // The modules to be run (from the flow hook) |
|
60 const TInt iChannelId; // > 0, if session associates with a channel |
|
61 |
|
62 TInt iError; // Error code |
|
63 TBool iFatalError; // If set, stop negotiation |
|
64 TUint16 iValue; // Return value |
|
65 TInt iCurrent; // The current module to be run (0..) |
|
66 TInt iProceed; // Non-zero when control in Proceed() |
|
67 TQoSParameters iNegotiated; // |
|
68 TPfqosMessage iMsg; // PF_QOS reply msg |
|
69 TSglQue<CNegotiateItem> iPending; // Pending request queue |
|
70 }; |
|
71 |
|
72 // Negotiate session |
|
73 class CNegotiateSession : public CQoSSessionBase |
|
74 { |
|
75 public: |
|
76 CNegotiateSession(CFlowHook& aHook); |
|
77 ~CNegotiateSession(); |
|
78 |
|
79 private: |
|
80 TInt DoCall(RModule& aModule, MQoSNegotiateEvent& aCallback); |
|
81 void RequestComplete(); |
|
82 }; |
|
83 |
|
84 |
|
85 // Create channel session |
|
86 class CCreateChannelSession : public CQoSSessionBase |
|
87 { |
|
88 public: |
|
89 CCreateChannelSession(CFlowHook& aHook, TInt aChannelId); |
|
90 ~CCreateChannelSession(); |
|
91 |
|
92 private: |
|
93 TInt DoCall(RModule &aModule, MQoSNegotiateEvent& aCallback); |
|
94 void RequestComplete(); |
|
95 }; |
|
96 |
|
97 |
|
98 // Negotiate channel session |
|
99 class CNegotiateChannelSession : public CQoSSessionBase |
|
100 { |
|
101 public: |
|
102 CNegotiateChannelSession(CFlowHook& aHook, TInt aChannelId); |
|
103 ~CNegotiateChannelSession(); |
|
104 |
|
105 private: |
|
106 TInt DoCall(RModule& aModule, MQoSNegotiateEvent& aCallback); |
|
107 void RequestComplete(); |
|
108 }; |
|
109 |
|
110 // Join session |
|
111 class CJoinSession : public CQoSSessionBase |
|
112 { |
|
113 public: |
|
114 CJoinSession(CFlowHook& aHook, TInt aChannelId); |
|
115 ~CJoinSession(); |
|
116 |
|
117 private: |
|
118 TInt DoCall(RModule& aModule, MQoSNegotiateEvent& aCallback); |
|
119 void RequestComplete(); |
|
120 }; |
|
121 |
|
122 // Leave session |
|
123 class CLeaveSession : public CQoSSessionBase |
|
124 { |
|
125 public: |
|
126 CLeaveSession(CFlowHook& aHook, TInt aChannelId); |
|
127 ~CLeaveSession(); |
|
128 |
|
129 private: |
|
130 TInt DoCall(RModule& aModule, MQoSNegotiateEvent& aCallback); |
|
131 void RequestComplete(); |
|
132 }; |
|
133 |
|
134 |
|
135 class CNegotiateItem : public CBase, public MQoSNegotiateEvent |
|
136 // BEWARE: |
|
137 // Once you start the negotiation and pass a reference of MQosNegotiateEvent |
|
138 // to the module, there is no way to cancel this request. This object MUST exist |
|
139 // until the RequestComplete is called! |
|
140 { |
|
141 public: |
|
142 ~CNegotiateItem(); |
|
143 CNegotiateItem(CQoSSessionBase* aSession, TUint aFlags); |
|
144 void Kill(); |
|
145 void RequestComplete(TInt aEvent, const TQoSParameters* aParams, const TExtensionData& aExtension); |
|
146 inline TUint Flags() const { return iFlags; }; |
|
147 |
|
148 TSglQueLink iLink; |
|
149 private: |
|
150 TUint iFlags; // Module flags |
|
151 CQoSSessionBase* iSession; // Session (or NULL, when ZOMBIE) |
|
152 }; |
|
153 |
|
154 #endif |