|
1 /* |
|
2 * Copyright (c) 2002-2006 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: The class for submitting synchronous requests via call |
|
15 * to asynchronous SendL of a certain MSenTransport instance |
|
16 * and making the ActiveScheduler to wait until a response |
|
17 * callback is received from the transport (typically a server |
|
18 * for certain networking stack). |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 #ifndef SEN_SYNC_REQUESTER_H |
|
33 #define SEN_SYNC_REQUESTER_H |
|
34 |
|
35 // INCLUDES |
|
36 #include <e32base.h> |
|
37 #include <e32std.h> |
|
38 |
|
39 #include "msenservicesession.h" |
|
40 #include "msenremoteserviceconsumer.h" |
|
41 #include "MSenProperties.h" |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 class MSenServiceSession; |
|
45 class MSenRemoteServiceConsumer; |
|
46 class MSenCoreServiceManager; |
|
47 class MSenTransport; |
|
48 class CSenGuidGen; |
|
49 class MSenRemoteHostlet; |
|
50 class MSenProperties; |
|
51 // CLASS DECLARATION |
|
52 |
|
53 /** |
|
54 * The class for submitting requests in a synchronous |
|
55 * *manner* using the async SendL implementation offered |
|
56 * by given MSenTransport reference. |
|
57 * |
|
58 * Any transport plug-in developer may wish to use this |
|
59 * class to implement SubmitL of her transport, using |
|
60 * the SendL method implementation of that transport. |
|
61 * In most of the cases, that is the most beneficial |
|
62 * way to implement SubmitL, blocking the caller's |
|
63 * ActiveScheduler execution until a response is |
|
64 * received. |
|
65 * |
|
66 * One can take a look of LocalTransportPlugin implementation |
|
67 * and use it as a reference of how this synchronous requester |
|
68 * class can be implemented. |
|
69 */ |
|
70 class CSenSyncRequester : public CBase, |
|
71 public MSenServiceSession, |
|
72 public MSenRemoteServiceConsumer |
|
73 { |
|
74 public: |
|
75 /** |
|
76 * Two-phased constructor. |
|
77 */ |
|
78 IMPORT_C static CSenSyncRequester* NewL(MSenTransport& aTransport, |
|
79 MSenCoreServiceManager& iServiceManager); |
|
80 |
|
81 /** |
|
82 * Two-phased constructor. |
|
83 */ |
|
84 IMPORT_C static CSenSyncRequester* NewLC(MSenTransport& aTransport, |
|
85 MSenCoreServiceManager& iServiceManager); |
|
86 |
|
87 /** |
|
88 * Destructor. |
|
89 */ |
|
90 IMPORT_C virtual ~CSenSyncRequester(); |
|
91 |
|
92 |
|
93 /** |
|
94 * Submit a synchronous HTTP POST request to a given URI using |
|
95 * the - asynchronous - SendL method of the MSenTransport that |
|
96 * this class is "wrapping". Any transport plugin, which wishes |
|
97 * to implement SubmitL by calling and waiting SendL to complete, |
|
98 * can use this method to implement their synchronous SubmitL |
|
99 * function. |
|
100 * |
|
101 * @param aRequestUri service endpoint (URI) for the outgoing message. |
|
102 * @param aMessage outgoing message content. |
|
103 * @param aRequestTransportProperties outgoing message properties |
|
104 * @param aResponseContent incoming response message (content). |
|
105 * @param aStatusCode the status code of the response message, |
|
106 * indicating whether or not an error occurred |
|
107 * @return a transaction id of the "wrapped" SendL, which is performed |
|
108 * inside this method, or error code, negative integer, if |
|
109 * sending of the message fails. |
|
110 */ |
|
111 virtual TInt SubmitL(const TDesC8& aEndpointUri, |
|
112 const TDesC8& aMessage, |
|
113 const TDesC8& aRequestTransportProperties, |
|
114 HBufC8*& apResponseTo); |
|
115 |
|
116 // Functions from base classes |
|
117 |
|
118 /** |
|
119 * from MSenServiceSession |
|
120 */ |
|
121 |
|
122 virtual TInt SendToConsumerL(HBufC8* apMessage, |
|
123 const TInt aTxnId, |
|
124 MSenRemoteServiceConsumer& aConsumer, |
|
125 MSenProperties* aResponseTransportProperties = NULL); |
|
126 |
|
127 virtual TInt SendErrorToConsumerL(const TInt aErrorCode, |
|
128 HBufC8* apError, |
|
129 const TInt aTxnId, |
|
130 MSenRemoteServiceConsumer& aConsumer, |
|
131 MSenProperties* aResponseTransportProperties = NULL); |
|
132 |
|
133 virtual TInt HandleErrorL(const TInt aErrorCode, |
|
134 HBufC8* apError, |
|
135 const TInt aTxnId, |
|
136 MSenRemoteServiceConsumer& aConsumer, |
|
137 MSenProperties* aResponseTransportProperties = NULL); |
|
138 /** |
|
139 * from MSenRemoteServiceConsumer |
|
140 */ |
|
141 virtual const TDesC8& Id() const; |
|
142 virtual TInt SetSessionL(MSenRemoteServiceSession& aServiceSession); |
|
143 virtual TInt HandleMessageL(HBufC8* apMessage, |
|
144 const TInt aTxnId, |
|
145 MSenProperties* aResponseTransportProperties); |
|
146 |
|
147 virtual TInt HandleErrorL(HBufC8* aError, |
|
148 const TInt aErrorCode, |
|
149 const TInt aTxnId, |
|
150 MSenProperties* aResponseTransportProperties); |
|
151 |
|
152 virtual void SetStatusL(const TInt aStatus); |
|
153 virtual MSenTransport& TransportL(); |
|
154 virtual CSenIdentifier& Identifier() const; |
|
155 virtual TInt ChunkByTxnIdL(TInt aTxnId, CSenChunk*& aChunk); |
|
156 virtual MSenRemoteHostlet* CSenSyncRequester::Hostlet() const; |
|
157 |
|
158 virtual TInt SendToHostletL(MSenRemoteHostlet& aReceiver, |
|
159 const TDesC8& aMessage, |
|
160 const TInt aTxnId, |
|
161 MSenRemoteServiceConsumer& aFrom, |
|
162 MSenProperties* aProperties = NULL); |
|
163 virtual void FileProgress(TInt aTxnId, TBool aIncoming, TBool aIsSoap, |
|
164 const TDesC8& aSoapOrCid, TInt aProgress); |
|
165 virtual void SetDataTrafficDetails( TSenDataTrafficDetails& aDetails); |
|
166 protected: |
|
167 IMPORT_C CSenSyncRequester(MSenTransport& aTransport, |
|
168 MSenCoreServiceManager& iServiceManager); |
|
169 |
|
170 IMPORT_C void BaseConstructL(); |
|
171 |
|
172 private: // Data |
|
173 MSenTransport& iTransport; |
|
174 MSenCoreServiceManager& iServiceManager; // for GUID generation API access etc |
|
175 CActiveSchedulerWait iSchedulerWait; |
|
176 |
|
177 CSenIdentifier* ipIdentifier; // owned |
|
178 HBufC8* ipConsumerId; // owned |
|
179 HBufC8* ipResponse; // owned |
|
180 HBufC8* ipResponseProperties; // owned, contains properties of the response |
|
181 MSenProperties::TSenPropertiesClassType iResponsePropertiesType; |
|
182 TInt iStatusCode; // contains KErrNone or some error |
|
183 }; |
|
184 |
|
185 #endif //SEN_SYNC_REQUESTER_H |
|
186 |
|
187 // End of File |