|
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_LOCAL_TRANSPORT_PLUGIN |
|
29 #define SEN_LOCAL_TRANSPORT_PLUGIN |
|
30 |
|
31 #include <e32base.h> |
|
32 #include <s32strm.h> |
|
33 #include <e32std.h> |
|
34 #include <flogger.h> |
|
35 |
|
36 #include "sentransport.h" |
|
37 #include "senpointermap.h" // from Utils\inc |
|
38 #include "senlayeredxmlproperties.h" |
|
39 |
|
40 // CONSTANTS |
|
41 _LIT8(KSenLocalTransportUriScheme, "local"); |
|
42 |
|
43 // FORWARD DECLARE |
|
44 class MSenProvider; |
|
45 class CSenProvider; |
|
46 class CSenLocalRequest; |
|
47 class CSenHostletRequest; |
|
48 class CSenHostletResponse; |
|
49 class CSenSyncRequester; |
|
50 |
|
51 // TYPEDEFS |
|
52 typedef RSenPointerMap<CSenLocalRequest, TInt> RLocalRequestMap; |
|
53 |
|
54 |
|
55 |
|
56 class CSenLocalTransportPlugin : public CSenTransport |
|
57 { |
|
58 public: |
|
59 |
|
60 // Constructors: |
|
61 static CSenLocalTransportPlugin* NewL(CSenTransportContext* apCtx); |
|
62 |
|
63 static CSenLocalTransportPlugin* NewLC(CSenTransportContext* apCtx); |
|
64 |
|
65 // Destructor: |
|
66 virtual ~CSenLocalTransportPlugin(); |
|
67 |
|
68 // from MSenTransport |
|
69 virtual TInt SubmitL(const TDesC8& aEndpoint, |
|
70 const TDesC8& aMessage, |
|
71 const TDesC8& aTransportProperties, |
|
72 HBufC8*& aResponse, |
|
73 MSenRemoteServiceConsumer& aConsumer); |
|
74 |
|
75 virtual TInt SendL(const TDesC8& aEndpoint, |
|
76 const TDesC8& aMessage, |
|
77 const TDesC8& aTransportProperties, |
|
78 MSenServiceSession& aReplyTo, |
|
79 MSenRemoteServiceConsumer& aConsumer, // "addressee", could be CSenIdentifier |
|
80 TInt& aTxnId); |
|
81 |
|
82 virtual TInt SetPropertiesL(const TDesC8& aProperties, |
|
83 MSenLayeredProperties::TSenPropertiesLayer aTargetLayer, |
|
84 MSenRemoteServiceConsumer* aConsumer); |
|
85 |
|
86 virtual TInt PropertiesL(HBufC8*& aProperties); |
|
87 virtual TInt CompleteTransaction(const TInt aTxnId, const TInt aStatus); |
|
88 virtual TInt CancelTransaction(const TInt aTxnId); |
|
89 virtual TPtrC8 CSenLocalTransportPlugin::UriSchemeL(); |
|
90 |
|
91 virtual MSenProperties& PropertiesL(); |
|
92 |
|
93 |
|
94 private: |
|
95 void ConstructL(); |
|
96 CSenLocalTransportPlugin(CSenTransportContext* apCtx); |
|
97 //RFileLogger* Log() const; |
|
98 |
|
99 // Helper, to locally "proxy" the provider, which was invoked *last* time |
|
100 MSenProvider& ProviderL(const TDesC8& aEndpoint); |
|
101 |
|
102 private: // member data |
|
103 CSenSyncRequester* ipRequester; |
|
104 CSenProvider* iInvokedProvider; |
|
105 //RFileLogger iLogger; |
|
106 TInt iStatusCode ; |
|
107 TInt iTransactionID; |
|
108 RLocalRequestMap iRequestMap; |
|
109 CSenLayeredXmlProperties* ipTransportProperties; |
|
110 } ; |
|
111 |
|
112 class CSenLocalRequest : public CActive |
|
113 { |
|
114 friend class CSenLocalTransportPlugin; |
|
115 |
|
116 |
|
117 |
|
118 public: |
|
119 |
|
120 enum TLocalRequestState |
|
121 { |
|
122 EInvokeService = 1, |
|
123 EDeliverResponse, |
|
124 EDeliverComplete |
|
125 }; |
|
126 |
|
127 // Standard 2 phased constructor |
|
128 static CSenLocalRequest* NewLC(const TDesC8& aEndpoint, //MSenProvider& aRequestTo, |
|
129 const TDesC8& aMessage, |
|
130 const TDesC8& aTransportProperties, |
|
131 MSenServiceSession& aReplyTo, |
|
132 MSenRemoteServiceConsumer& aConsumer, // "addressee", could be CSenIdentifier |
|
133 MSenCoreServiceManager& aProviderProxy, |
|
134 TInt aTxnId); |
|
135 |
|
136 // C++ destructor |
|
137 virtual ~CSenLocalRequest(); |
|
138 |
|
139 MSenServiceSession& Session() const; |
|
140 MSenRemoteServiceConsumer& Consumer() const; |
|
141 TInt TxnId() const; |
|
142 |
|
143 TPtrC8 TransportProperties() const; |
|
144 |
|
145 virtual void RunL(); |
|
146 virtual void DoCancel(); |
|
147 |
|
148 //void SetLogger(RFileLogger& aLogger); |
|
149 |
|
150 void ExecuteL(); // called by thread |
|
151 |
|
152 const TThreadId OwnerThreadId() const; |
|
153 |
|
154 CSenHostletResponse& Response(); |
|
155 |
|
156 TBool Delivered() const; |
|
157 |
|
158 static void LocalRequestExceptionHandlerL(TExcType aType); |
|
159 |
|
160 |
|
161 private: |
|
162 // 2nd phase constructor |
|
163 void ConstructL(const TDesC8& aMessage, |
|
164 const TDesC8& aTransportProperties); |
|
165 |
|
166 // C++ constructor |
|
167 CSenLocalRequest(const TDesC8& aEndpoint, //MSenProvider& aRequestTo, |
|
168 MSenServiceSession& aReplyTo, |
|
169 MSenRemoteServiceConsumer& aConsumer, // "addressee", could be CSenIdentifier |
|
170 MSenCoreServiceManager& aProviderProxy, |
|
171 TInt aTxnId |
|
172 ); |
|
173 //RFileLogger* Log() const; |
|
174 |
|
175 void DeliverL(); // Send the response back to the consumer, who invoked the service provider |
|
176 |
|
177 private: // Data |
|
178 MSenProvider* ipProvider; // not owned |
|
179 const TDesC8& iEndpoint; |
|
180 MSenCoreServiceManager& iProviderProxy; |
|
181 CSenHostletRequest* ipRequestImpl; |
|
182 CSenHostletResponse* ipResponseImpl; |
|
183 |
|
184 HBufC8* ipTransportProperties; |
|
185 MSenServiceSession& iReplyTo; |
|
186 MSenRemoteServiceConsumer& iConsumer; // holds CSenIdentifier, the requester |
|
187 TInt iTxnId; |
|
188 //RFileLogger* iLogger; |
|
189 TThreadId iOwnerThreadId; |
|
190 RThread iThread; |
|
191 TInt iLeaveCode; // place holder for leave code |
|
192 TInt iRetVal; // place holder for return code |
|
193 TBool iDelivered; |
|
194 // ownership is transferred if response is delivered otherwise to be cleaned up |
|
195 HBufC8* ipResponse; |
|
196 }; |
|
197 |
|
198 #endif // SEN_LOCAL_TRANSPORT_PLUGIN |