1 /* |
|
2 * Copyright (c) 2004 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: Messenger Request Manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPHSRVMESSENGERREQUESTMANAGER_H |
|
20 #define CPHSRVMESSENGERREQUESTMANAGER_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "mphsrvmessengernegotiators.h" |
|
26 #include <cphcltcommandhandler.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CPhSrvMessengerObject; |
|
30 class CPhSrvServer; |
|
31 |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 // Type for array used in this class. |
|
36 typedef RPointerArray< CPhSrvMessengerObject > RMessengerArray; |
|
37 |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Messenger request manager. |
|
43 * |
|
44 * @since 2.6 |
|
45 */ |
|
46 class CPhSrvMessengerRequestManager |
|
47 : public CBase, |
|
48 public MPhSrvMessengerNegotiator |
|
49 { |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Constructor. |
|
54 * |
|
55 * @param aServer The server instance. |
|
56 */ |
|
57 CPhSrvMessengerRequestManager( CPhSrvServer& aServer ); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CPhSrvMessengerRequestManager(); |
|
63 |
|
64 /** |
|
65 * Symbian 2nd phase constructor. |
|
66 */ |
|
67 void ConstructL(); |
|
68 |
|
69 |
|
70 public: // Functions from base classes |
|
71 |
|
72 /** |
|
73 * @see MPhSrvMessengerNegotiators |
|
74 */ |
|
75 void NegotiatorRequest( |
|
76 CPhSrvSubSessionBase& aSubSession, |
|
77 const TPhCltMessengerParameters& aParameters, |
|
78 const RMessage2& aMessage ); |
|
79 |
|
80 /** |
|
81 * @see MPhSrvMessengerNegotiators |
|
82 */ |
|
83 void NegotiatorRequestCancel( |
|
84 CPhSrvSubSessionBase& aSubSession, |
|
85 const TPhCltMessengerCommand aRequestType ); |
|
86 |
|
87 /** |
|
88 * @see MPhSrvMessengerNegotiators |
|
89 */ |
|
90 void NegotiatorRequestConstructL( |
|
91 CPhSrvSubSessionBase& aSubSession, |
|
92 const TPhCltMessengerParameters& aParameters, |
|
93 const RMessage2& aMessage ); |
|
94 |
|
95 /** |
|
96 * @see MPhSrvMessengerNegotiators |
|
97 */ |
|
98 void NegotiatorRequestDelete( |
|
99 CPhSrvSubSessionBase& aSubSession ); |
|
100 |
|
101 |
|
102 private: |
|
103 |
|
104 /** |
|
105 * Updates the request objects. |
|
106 * |
|
107 * @param aEntry The entry whose information is updated. |
|
108 * @param aCommand The command that was performed for aEntry. |
|
109 */ |
|
110 void UpdateMessengerChain( |
|
111 CPhSrvMessengerObject* aEntry, |
|
112 TPhCltMessengerCommand aCommand ); |
|
113 |
|
114 /** |
|
115 * Handle all Send requests at one time. |
|
116 * |
|
117 * @param aEntry The object whose information is updated. |
|
118 * @param aSendArray The send array that is handled. |
|
119 */ |
|
120 void HandleAllSendRequests( |
|
121 CPhSrvMessengerObject* aEntry, |
|
122 RMessengerArray* aSendArray ); |
|
123 |
|
124 /** |
|
125 * Handles the Send Requests. |
|
126 * |
|
127 * @param aEntry The entry whose information is updated. |
|
128 * @param aSendArray The send array that is handled. |
|
129 * @return ETrue if Send was fully handled, EFalse otherwise. |
|
130 */ |
|
131 TBool HandleSendRequest( |
|
132 CPhSrvMessengerObject* aEntry, |
|
133 RMessengerArray* aSendArray ); |
|
134 |
|
135 /** |
|
136 * Checks whether there already is active request from this client |
|
137 * (subsession). Checks Send,Receive and Skip requests. |
|
138 * If request is not active, then sets it active. |
|
139 * |
|
140 * @param aSubSession The client who's requests are searched. |
|
141 * @param aParameters Contains the request type that is checked. |
|
142 * If not active, sets the given request to be active. |
|
143 * @param aMessage The received message. |
|
144 |
|
145 * @return ETrue if there already was request from this client, |
|
146 * otherwise EFalse. |
|
147 */ |
|
148 TBool RequestAlreadyExists( |
|
149 const CPhSrvSubSessionBase& aSubSession, |
|
150 const TPhCltMessengerParameters& aParameters, |
|
151 const RMessage2& aMessage ); |
|
152 |
|
153 |
|
154 /** |
|
155 * Returns the correct array which contains messenger objects. |
|
156 * |
|
157 * @return The array containing the messenger objects. |
|
158 */ |
|
159 RMessengerArray* MessengerArray(); |
|
160 |
|
161 |
|
162 /** |
|
163 * Returns the correct array which contains send chain. |
|
164 * |
|
165 * @return The array containing the send chain. |
|
166 */ |
|
167 RMessengerArray* SendChain(); |
|
168 |
|
169 |
|
170 private: // Data |
|
171 |
|
172 // A list of request objects received from external Messenger interface. |
|
173 // Messenger request manager completes them sequentially |
|
174 // after its finished the previous request. |
|
175 RMessengerArray* iMessengerObjects; |
|
176 |
|
177 // The server instance. |
|
178 CPhSrvServer& iServer; |
|
179 |
|
180 // A FIFO chain of Send requests made by the external Messenger |
|
181 // interface clients. They are completed sequentially. |
|
182 RMessengerArray* iSendChain; |
|
183 |
|
184 // The object whose Receive / Skip is waited. |
|
185 CPhSrvMessengerObject* iRequestObject; |
|
186 |
|
187 // The variable for Ids for sent messages. |
|
188 TUint iSentDataIdGenerator; |
|
189 |
|
190 // The pointer to hold the default size (KPhCltDefMesSize) |
|
191 // buffer at startup, exist always if construction valid. |
|
192 // This buffer can be changed to bigger one during execution |
|
193 // if memory allocation is successful. |
|
194 HBufC8* iDefaultSizeBuffer; |
|
195 |
|
196 // Tells whether there is Send operation ongoing or not. |
|
197 // ETrue if Send request have been processed at least once but not |
|
198 // completed yet. |
|
199 TBool iSendProcessOngoing; |
|
200 |
|
201 }; |
|
202 |
|
203 |
|
204 #endif // CPHSRVMESSENGERREQUESTMANAGER_H |
|
205 |
|
206 |
|
207 // End of File |
|