|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Header declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 #ifndef SEN_HOSTLET_TRANSPORT_PLUGIN |
|
29 #define SEN_HOSTLET_TRANSPORT_PLUGIN |
|
30 |
|
31 #include <e32base.h> |
|
32 #include <s32strm.h> |
|
33 #include <e32std.h> |
|
34 |
|
35 #include <MSenProperties.h> |
|
36 |
|
37 #include "sentransport.h" |
|
38 #include "senpointermap.h" // from Utils\inc |
|
39 |
|
40 |
|
41 // CONSTANTS |
|
42 _LIT8(KSenHostletTransportUriScheme, "hostlet"); |
|
43 |
|
44 // FORWARD DECLARE |
|
45 class MSenProvider; |
|
46 class CSenProvider; |
|
47 class CSenActiveHostletRequest; |
|
48 class CSenHostletRequest; |
|
49 class CSenHostletResponse; |
|
50 class CSenSyncRequester; |
|
51 class CSenLayeredXmlProperties; |
|
52 class CSenTransportProperties; |
|
53 class MSenTransportContext; |
|
54 |
|
55 // TYPEDEFS |
|
56 typedef RSenPointerMap<MSenRemoteServiceConsumer, TInt> RConsumerMap; |
|
57 typedef RSenPointerMap<MSenServiceSession, TInt> RSessionMap; |
|
58 |
|
59 typedef RSenPointerMap<CSenActiveHostletRequest, TInt> RLocalRequestMap; |
|
60 |
|
61 |
|
62 |
|
63 class CSenHostletTransportPlugin : public CSenTransport |
|
64 { |
|
65 public: |
|
66 |
|
67 // Constructors: |
|
68 static CSenHostletTransportPlugin* NewL(CSenTransportContext* apCtx); |
|
69 static CSenHostletTransportPlugin* NewLC(CSenTransportContext* apCtx); |
|
70 |
|
71 // Destructor: |
|
72 virtual ~CSenHostletTransportPlugin(); |
|
73 |
|
74 // from MSenTransport |
|
75 virtual TInt SubmitL(const TDesC8& aEndpoint, |
|
76 const TDesC8& aMessage, |
|
77 const TDesC8& aTransportProperties, |
|
78 HBufC8*& aResponse, |
|
79 MSenRemoteServiceConsumer& aConsumer); |
|
80 |
|
81 virtual TInt SendL(const TDesC8& aEndpoint, |
|
82 const TDesC8& aMessage, |
|
83 const TDesC8& aTransportProperties, |
|
84 MSenServiceSession& aReplyTo, |
|
85 MSenRemoteServiceConsumer& aConsumer, // "addressee", could be CSenIdentifier |
|
86 TInt& aTxnId); |
|
87 |
|
88 virtual TInt SetPropertiesL(const TDesC8& aProperties, |
|
89 MSenLayeredProperties::TSenPropertiesLayer aTargetLayer, |
|
90 MSenRemoteServiceConsumer* aConsumer); |
|
91 virtual TInt PropertiesL(HBufC8*& aProperties); |
|
92 virtual TInt CompleteTransaction(const TInt aTxnId, const TInt aStatus = KErrNone); |
|
93 virtual TInt CancelTransaction(const TInt aTxnId); |
|
94 virtual TPtrC8 CSenHostletTransportPlugin::UriSchemeL(); |
|
95 |
|
96 virtual MSenProperties& PropertiesL(); |
|
97 |
|
98 //RConsumerMap ConsumerMap(); |
|
99 //RSessionMap SessionMap(); |
|
100 |
|
101 private: |
|
102 void ConstructL(); |
|
103 CSenHostletTransportPlugin(CSenTransportContext* apCtx); |
|
104 |
|
105 // Helper, to locally "proxy" the provider, which was invoked *last* time |
|
106 MSenProvider& ProviderL(const TDesC8& aEndpoint); |
|
107 |
|
108 private: // member data |
|
109 CSenSyncRequester* ipRequester; |
|
110 CSenProvider* iInvokedProvider; |
|
111 TInt iStatusCode ; |
|
112 TInt iTransactionID; |
|
113 //RConsumerMap iConsumerMap; // values owned (TxnIds), keys not (consumers) |
|
114 //RSessionMap iSessionMap; // values NOT owned (TxnIds), neither keys (sessions) |
|
115 RLocalRequestMap iRequestMap; |
|
116 CSenLayeredXmlProperties* ipLayeredXmlProperties; |
|
117 } ; |
|
118 |
|
119 class CSenActiveHostletRequest : public CActive |
|
120 { |
|
121 friend class CSenHostletTransportPlugin; |
|
122 |
|
123 |
|
124 |
|
125 public: |
|
126 |
|
127 enum TLocalRequestState |
|
128 { |
|
129 EInvokeService = 1, |
|
130 ECompleteTransaction |
|
131 }; |
|
132 |
|
133 // Standard 2 phased constructor |
|
134 static CSenActiveHostletRequest* NewLC(const TDesC8& aEndpoint, |
|
135 MSenServiceSession& aReplyTo, |
|
136 MSenRemoteServiceConsumer& aConsumer, |
|
137 TInt aTxnId, |
|
138 RLocalRequestMap& aRequestMap, |
|
139 MSenTransport& aParent, |
|
140 MSenTransportContext& aParentCtx); |
|
141 |
|
142 // C++ destructor |
|
143 virtual ~CSenActiveHostletRequest(); |
|
144 |
|
145 MSenServiceSession& Session() const; |
|
146 MSenRemoteServiceConsumer& Consumer() const; |
|
147 TInt TxnId() const; |
|
148 // TPtrC8 TransportProperties() const; |
|
149 RLocalRequestMap& RequestMap(); |
|
150 |
|
151 // This method is called when txn is ready to be completed |
|
152 // Note that this sets this AO in active state(!) |
|
153 TInt Complete(TRequestStatus*& aStatus, TInt aCompletionCode = KErrNone); |
|
154 |
|
155 virtual void RunL(); |
|
156 virtual void DoCancel(); |
|
157 virtual TInt RunError(TInt aError); |
|
158 |
|
159 private: |
|
160 // 2nd phase constructor |
|
161 void ConstructL(); |
|
162 |
|
163 // C++ constructor |
|
164 CSenActiveHostletRequest(const TDesC8& aEndpoint, |
|
165 MSenServiceSession& aReplyTo, |
|
166 MSenRemoteServiceConsumer& aConsumer, |
|
167 TInt aTxnId, |
|
168 RLocalRequestMap& aRequestMap, |
|
169 MSenTransport& aParent, |
|
170 MSenTransportContext& aParentCtx); |
|
171 |
|
172 CSenChunk* CSenActiveHostletRequest::FindChunkL(const TInt aTxnId, TInt& aIndex) ; |
|
173 |
|
174 CSenTransportProperties* NewPropertiesByTypeL( MSenProperties::TSenPropertiesClassType aType, const TDesC8& aPropertiesAsXml ); |
|
175 |
|
176 private: // Data |
|
177 const TDesC8& iEndpoint; |
|
178 TInt iCompletionCode; |
|
179 MSenServiceSession& iReplyTo; |
|
180 MSenRemoteServiceConsumer& iConsumer; |
|
181 TInt iTxnId; |
|
182 RLocalRequestMap& iRequestMap; |
|
183 MSenTransport& iParent; |
|
184 MSenTransportContext& iParentContext; |
|
185 TPtrC8 iMessage; |
|
186 TPtrC8 iProperties; |
|
187 |
|
188 }; |
|
189 |
|
190 #endif // SEN_HOSTLET_TRANSPORT_PLUGIN |