70 TInt NativeHttpTransaction::NewL(JNIEnv &aJni, jobject aPeer, HttpSessionClient& aSession, |
70 TInt NativeHttpTransaction::NewL(JNIEnv &aJni, jobject aPeer, HttpSessionClient& aSession, |
71 const TDesC* aUri, const TDesC* aRequestMethod,java::util::FunctionServer* aFuncServer) |
71 const TDesC* aUri, const TDesC* aRequestMethod,java::util::FunctionServer* aFuncServer) |
72 { |
72 { |
73 NativeHttpTransaction* self = new(ELeave) NativeHttpTransaction(aSession,aFuncServer); |
73 NativeHttpTransaction* self = new(ELeave) NativeHttpTransaction(aSession,aFuncServer); |
74 |
74 |
75 |
75 |
76 self->ConstructL(aJni, aPeer, /*aServer, */ aUri, aRequestMethod); |
76 self->ConstructL(aJni, aPeer, /*aServer, */ aUri, aRequestMethod); |
77 |
77 |
78 |
78 |
79 // Pop the cleanup of the object and create a handle: |
79 // Pop the cleanup of the object and create a handle: |
80 return reinterpret_cast<int>(self); //selfCleanup.GetHandle(); |
80 return reinterpret_cast<int>(self); //selfCleanup.GetHandle(); |
91 // iFuncServer->attachToVm(aJni, aPeer); |
91 // iFuncServer->attachToVm(aJni, aPeer); |
92 int handle = reinterpret_cast<int>(this); |
92 int handle = reinterpret_cast<int>(this); |
93 int urihandle = reinterpret_cast<int>(aUri); |
93 int urihandle = reinterpret_cast<int>(aUri); |
94 int methodhandle = reinterpret_cast<int>(aRequestMethod); |
94 int methodhandle = reinterpret_cast<int>(aRequestMethod); |
95 //open the transaction |
95 //open the transaction |
96 |
96 |
97 CallMethodL(this, &NativeHttpTransaction::ExecuteCreateTransactionL,handle,urihandle , methodhandle, iFuncServer); |
97 CallMethodL(this, &NativeHttpTransaction::ExecuteCreateTransactionL,handle,urihandle , methodhandle, iFuncServer); |
98 |
98 |
99 } |
99 } |
100 |
100 |
101 void NativeHttpTransaction::ExecuteCreateTransactionL(int aSelfhandle, int aUrihandle, int aMethodhandle) |
101 void NativeHttpTransaction::ExecuteCreateTransactionL(int aSelfhandle, int aUrihandle, int aMethodhandle) |
102 { |
102 { |
103 NativeHttpTransaction* aSelf = reinterpret_cast<NativeHttpTransaction*>(aSelfhandle); |
103 NativeHttpTransaction* aSelf = reinterpret_cast<NativeHttpTransaction*>(aSelfhandle); |
171 CleanupStack::PopAndDestroy();//rawHeaderArray; |
171 CleanupStack::PopAndDestroy();//rawHeaderArray; |
172 } |
172 } |
173 |
173 |
174 void NativeHttpTransaction::ExecuteSubmitL(int aSelfhandle , int aRawHeadershandle , int aPostBufhandle, int aResponseTimeout) |
174 void NativeHttpTransaction::ExecuteSubmitL(int aSelfhandle , int aRawHeadershandle , int aPostBufhandle, int aResponseTimeout) |
175 { |
175 { |
176 |
176 |
177 NativeHttpTransaction *aSelf = reinterpret_cast<NativeHttpTransaction*>(aSelfhandle); |
177 NativeHttpTransaction *aSelf = reinterpret_cast<NativeHttpTransaction*>(aSelfhandle); |
178 RPointerArray<HBufC8>* aRawHeaders = reinterpret_cast<RPointerArray<HBufC8>*>(aRawHeadershandle); |
178 RPointerArray<HBufC8>* aRawHeaders = reinterpret_cast<RPointerArray<HBufC8>*>(aRawHeadershandle); |
179 HBufC8* aPostBuf = reinterpret_cast<HBufC8*>(aPostBufhandle); |
179 HBufC8* aPostBuf = reinterpret_cast<HBufC8*>(aPostBufhandle); |
180 |
180 |
181 aSelf->iTransactionClient->SubmitL(aRawHeaders, aPostBuf, aResponseTimeout); |
181 aSelf->iTransactionClient->SubmitL(aRawHeaders, aPostBuf, aResponseTimeout); |
184 jobjectArray NativeHttpTransaction::GetResponseL(JNIEnv* aJni) |
184 jobjectArray NativeHttpTransaction::GetResponseL(JNIEnv* aJni) |
185 { |
185 { |
186 jobjectArray objArray=NULL; |
186 jobjectArray objArray=NULL; |
187 RPointerArray<HBufC8> rawHeaders(KResponseGranularity); |
187 RPointerArray<HBufC8> rawHeaders(KResponseGranularity); |
188 CleanupStack::PushL(TCleanupItem(CleanUpResetAndDestroy,&rawHeaders)); |
188 CleanupStack::PushL(TCleanupItem(CleanUpResetAndDestroy,&rawHeaders)); |
189 |
189 |
190 int handle = reinterpret_cast<int>(this); |
190 int handle = reinterpret_cast<int>(this); |
191 |
191 |
192 int arrayhandle = reinterpret_cast<int>(&rawHeaders); |
192 int arrayhandle = reinterpret_cast<int>(&rawHeaders); |
193 CallMethodL(this, &NativeHttpTransaction::ExecuteGetResponseL,handle,arrayhandle , iFuncServer); |
193 CallMethodL(this, &NativeHttpTransaction::ExecuteGetResponseL,handle,arrayhandle , iFuncServer); |
194 |
194 |
195 const TInt headerCount = rawHeaders.Count(); |
195 const TInt headerCount = rawHeaders.Count(); |
196 if (headerCount>KErrNone) |
196 if (headerCount>KErrNone) |
197 { |
197 { |
198 jclass stringClass = aJni->FindClass("java/lang/String"); |
198 jclass stringClass = aJni->FindClass("java/lang/String"); |
199 User::LeaveIfNull(stringClass); |
199 User::LeaveIfNull(stringClass); |
230 * or -1 if there is no more data because the end of the stream |
230 * or -1 if there is no more data because the end of the stream |
231 * has been reached. |
231 * has been reached. |
232 */ |
232 */ |
233 TInt NativeHttpTransaction::ReadBytes(TUint8* aBytes, TInt aLength) |
233 TInt NativeHttpTransaction::ReadBytes(TUint8* aBytes, TInt aLength) |
234 { |
234 { |
235 |
235 |
236 int handle = reinterpret_cast<int>(this); |
236 int handle = reinterpret_cast<int>(this); |
237 int uinthandle = reinterpret_cast<int>(aBytes); |
237 int uinthandle = reinterpret_cast<int>(aBytes); |
238 |
238 |
239 int ret = 0; |
239 int ret = 0; |
240 CallMethod(ret,this, &NativeHttpTransaction::ExecuteReadBytes,handle,uinthandle,aLength,iFuncServer); |
240 CallMethod(ret,this, &NativeHttpTransaction::ExecuteReadBytes,handle,uinthandle,aLength,iFuncServer); |
241 |
241 |
242 return ret; |
242 return ret; |
243 |
243 |
244 } |
244 } |
245 |
245 |
246 TInt NativeHttpTransaction::ExecuteReadBytes(int aSelfhandle, int aByteshandle, TInt aLength) |
246 TInt NativeHttpTransaction::ExecuteReadBytes(int aSelfhandle, int aByteshandle, TInt aLength) |
247 { |
247 { |
248 NativeHttpTransaction *aSelf = reinterpret_cast<NativeHttpTransaction*>(aSelfhandle); |
248 NativeHttpTransaction *aSelf = reinterpret_cast<NativeHttpTransaction*>(aSelfhandle); |