2 * Copyright (C) 2013 HERE Global B.V. All rights reserved.
3 * This software, including documentation, is protected by copyright controlled by
4 * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
5 * storing, adapting or translating, any or all of this material requires the prior
6 * written consent of HERE Global B.V. You may use this
7 * Software in accordance with the terms and conditions defined in the
8 * HERE Location Platform Services Terms and Conditions, available at
9 * http://developer.here.com/terms-conditions-base
11 * As an additional permission to the above, you may distribute Software,
12 * in object code format as part of an Application, according to, and subject to, terms and
13 * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
14 * You may distribute such object code format Application under terms of your choice,
15 * provided that the header and source files of the Software have not been modified.
21 #include "common/HereMaps_global.h"
23 #ifndef TIZEN_MIGRATION
24 #include <FBaseObject.h>
25 #include <FBaseRtEventDrivenThread.h>
26 #include <FNetHttpIHttpTransactionEventListener.h>
29 #include "common/QueryListener.h"
30 #include "common/RestItemHandle.h"
32 #ifdef TIZEN_MIGRATION
33 #include "base/BaseObject.h"
34 #include "base/BaseByteBuffer.h"
35 #include "base/EventDrivenThread.h"
36 #include "internal/RestCurl.h"
38 using namespace Tizen::Maps;
40 using namespace Tizen::Base::Runtime;
43 HERE_MAPS_BEGIN_NAMESPACE
49 class RestEngineArgument
50 : public Tizen::Maps::Object
53 #ifdef TIZEN_SUPPORT_POST_METHOD
54 RestEngineArgument(const String& sUrl, RestItem* pRestItem,
55 bool bPost = false, const String& sPostData = "")
57 , m_pRestItem(pRestItem)
59 , m_sPostData(sPostData)
61 RestEngineArgument(const String& sUrl, RestItem* pRestItem)
63 , m_pRestItem(pRestItem)
66 #ifdef TIZEN_MIGRATION
67 m_aRequestId = RestItemHandle::INVALID_RESTITEM;
71 RestEngineArgument(RestItemHandle::RequestId aRequestId)
72 : m_aRequestId(aRequestId)
74 #ifdef TIZEN_MIGRATION
76 #ifdef TIZEN_SUPPORT_POST_METHOD
82 RestEngineArgument(RestItem* pRestItem)
83 : m_pRestItem(pRestItem)
85 #ifdef TIZEN_MIGRATION
86 m_aRequestId = RestItemHandle::INVALID_RESTITEM;
87 #ifdef TIZEN_SUPPORT_POST_METHOD
98 RestItem* m_pRestItem;
99 RestItemHandle::RequestId m_aRequestId;
100 #ifdef TIZEN_MIGRATION
101 Tizen::Maps::MemoryStruct_s m_Chunk;
103 #ifdef TIZEN_SUPPORT_POST_METHOD
109 //this is an internal class and should not be used outside
111 : public EventDrivenThread
112 #ifndef TIZEN_MIGRATION
113 , public Tizen::Net::Http::IHttpTransactionEventListener
117 static RestEngine& GetInstance();
119 #ifdef TIZEN_SUPPORT_POST_METHOD
120 RestItemHandle::RequestId OpenRequest(const String& sUrl, QueryListener* pListener, BaseReplyPtr pReply,
121 bool bPost = false, const String& sPostData = "");
123 RestItemHandle::RequestId OpenRequest(const String& sUrl, QueryListener* pListener, BaseReplyPtr pReply);
125 size_t GetNumPendingRequests() const;
126 void ShutdownEngine();
127 void AbortRequest(RestItemHandle::RequestId aRequestId);
128 void AbortListenerRequests(QueryListener* pListener);
129 void AbortAllRequests();
130 void UnregisterListener(QueryListener* pListener);
132 int CountListeners() const;
134 static unsigned int GetMaxPendingRequests();
136 #ifdef TIZEN_MIGRATION
137 void FireImpl(void* pArgs);
148 bool CheckRequestIn(RestItem* pRestItem);
149 RestItem* GetChechedInRequest(RestItemHandle::RequestId aRequestId) const;
151 void CloseRestItemLater(RestItemHandle::RequestId aRequestId);
152 void CloseRestItem(RestItemHandle::RequestId aRequestId, bool bDeleteLater = false);
153 void DeleteRestItemLater(RestItem* pRestItem);
155 #ifdef TIZEN_MIGRATION
156 void OnUserEventReceivedN(int requestType, void *pArgs);
158 void OnTransactionAborted(Tizen::Net::Http::HttpSession& httpSession,
159 Tizen::Net::Http::HttpTransaction& httpTransaction, result r);
161 void OnTransactionCertVerificationRequiredN(Tizen::Net::Http::HttpSession& httpSession,
162 Tizen::Net::Http::HttpTransaction& httpTransaction,
163 Tizen::Base::String* pCert);
165 void OnTransactionCompleted(Tizen::Net::Http::HttpSession& httpSession,
166 Tizen::Net::Http::HttpTransaction& httpTransaction);
168 void OnTransactionHeaderCompleted(Tizen::Net::Http::HttpSession& httpSession,
169 Tizen::Net::Http::HttpTransaction& httpTransaction,
173 void OnTransactionReadyToRead(Tizen::Net::Http::HttpSession& httpSession,
174 Tizen::Net::Http::HttpTransaction& httpTransaction,
175 int availableBodyLen);
177 void OnTransactionReadyToWrite(Tizen::Net::Http::HttpSession& httpSession,
178 Tizen::Net::Http::HttpTransaction& httpTransaction,
179 int recommendedChunkSize);
181 void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs);
189 void LockPendingRequests() const;
190 void UnlockPendingRequests() const;
192 void LockListenersRegistery() const;
193 void UnlockListenersRegistery() const;
198 void RegisterListener(QueryListener* rListener);
200 #ifdef TIZEN_SUPPORT_POST_METHOD
201 bool DoOpenRequest(const String& sUrl, RestItem* pRestItem,
202 bool bPost = false, const String& sPostData = "");
204 bool DoOpenRequest(const String& sUrl, RestItem* pRestItem);
206 void DoCloseRestItemLater(RestItemHandle::RequestId aRequestId);
207 void DoDeleteRestItemLater(RestItem* pRestItem);
209 //classes allowed to access this internal instance
210 friend class RestItem;
211 friend class QueryListener;
212 #ifdef TIZEN_SUPPORT_TILE_FILE_CACHE
213 friend class TileFetcherQuery;
217 class RestEngineImpl;
218 RestEngineImpl* m_pImpl;
221 HERE_MAPS_END_NAMESPACE