Merge lp:~marcustomlinson/unity-scopes-api/switch-to-net-cpp-rtm into lp:unity-scopes-api/rtm-14.09

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michi Henning
Approved revision: 267
Merged at revision: 262
Proposed branch: lp:~marcustomlinson/unity-scopes-api/switch-to-net-cpp-rtm
Merge into: lp:unity-scopes-api/rtm-14.09
Prerequisite: lp:~marcustomlinson/unity-scopes-api/lp-1410125-rtm
Diff against target: 1357 lines (+356/-694)
19 files modified
CMakeLists.txt (+28/-45)
debian/control (+1/-1)
include/unity/scopes/OnlineAccountClient.h (+1/-1)
include/unity/scopes/internal/smartscopes/HttpClientInterface.h (+1/-1)
include/unity/scopes/internal/smartscopes/HttpClientNetCpp.h (+78/-0)
include/unity/scopes/internal/smartscopes/HttpClientQt.h (+0/-94)
include/unity/scopes/internal/smartscopes/HttpClientQtThread.h (+0/-103)
src/scopes/internal/JsonCppNode.cpp (+4/-4)
src/scopes/internal/RegistryObject.cpp (+1/-1)
src/scopes/internal/smartscopes/CMakeLists.txt (+2/-31)
src/scopes/internal/smartscopes/HttpClientNetCpp.cpp (+189/-0)
src/scopes/internal/smartscopes/HttpClientQt.cpp (+0/-147)
src/scopes/internal/smartscopes/HttpClientQtThread.cpp (+0/-180)
src/scopes/internal/smartscopes/SSRegistryObject.cpp (+2/-2)
src/scopes/internal/smartscopes/SmartScopesClient.cpp (+39/-31)
test/gtest/scopes/internal/smartscopes/HttpClient/HttpClient_test.cpp (+3/-3)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py (+4/-1)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp (+3/-3)
valgrind-suppress (+0/-46)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/switch-to-net-cpp-rtm
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
Review via email: mp+247416@code.launchpad.net

Commit message

Switch from QNetwork to net-cpp

Description of the change

Switch from QNetwork to net-cpp

This change has been on our backlog for some time now (Bug #1326816), but due to a recent issue we started experiencing with QNetwork (Bug #1409995) we are taking the opportunity now to make the switch over to net-cpp.

To post a comment you must log in.
Revision history for this message
Michi Henning (michihenning) wrote :

Looking good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-12-12 12:44:10 +0000
3+++ CMakeLists.txt 2015-01-23 12:23:19 +0000
4@@ -67,8 +67,30 @@
5 pkg_check_modules(LTTNG_UST lttng-ust REQUIRED)
6 pkg_check_modules(LIBURCU_BP liburcu-bp REQUIRED)
7 pkg_check_modules(JSONCPP jsoncpp REQUIRED)
8-pkg_check_modules(LIBACCOUNTS REQUIRED libaccounts-glib)
9-pkg_check_modules(LIBSIGNON REQUIRED libsignon-glib)
10+pkg_check_modules(LIBACCOUNTS libaccounts-glib REQUIRED)
11+pkg_check_modules(LIBSIGNON libsignon-glib REQUIRED)
12+pkg_check_modules(ZMQLIB libzmq REQUIRED)
13+pkg_check_modules(NET_CPP net-cpp REQUIRED)
14+
15+find_library(ZMQPPLIB zmqpp)
16+if(NOT ZMQPPLIB)
17+ message(FATAL_ERROR "libzmqpp-dev not found.")
18+endif()
19+
20+find_library(CAPNPLIB capnp)
21+if(NOT CAPNPLIB)
22+ message(FATAL_ERROR "libcapnp-dev not found.")
23+endif()
24+
25+find_library(KJLIB kj)
26+if(NOT KJLIB)
27+ message(FATAL_ERROR "capnproto not found.")
28+endif()
29+
30+find_library(DLLIB dl)
31+if(NOT DLLIB)
32+ message(FATAL_ERROR "dl lib not found.")
33+endif()
34
35 find_program(LTTNG_EXECUTABLE lttng)
36 if (NOT LTTNG_EXECUTABLE)
37@@ -113,8 +135,10 @@
38
39 set(OTHER_INCLUDE_DIRS ${OTHER_INCLUDE_DIRS} ${UNITY_API_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
40 ${JSONCPP_INCLUDE_DIRS} ${PROCESS_CPP_INCLUDE_DIRS} ${APPARMOR_INCLUDE_DIRS}
41- ${LIBACCOUNTS_INCLUDE_DIRS} ${LIBSIGNON_INCLUDE_DIRS})
42-set(OTHER_LIBS ${OTHER_LIBS} ${UNITY_API_LDFLAGS} ${APPARMOR_LDFLAGS} ${LIBACCOUNTS_LIBRARIES} ${LIBSIGNON_LIBRARIES})
43+ ${LIBACCOUNTS_INCLUDE_DIRS} ${LIBSIGNON_INCLUDE_DIRS} ${NET_CPP_INCLUDE_DIRS})
44+set(OTHER_LIBS ${OTHER_LIBS} ${UNITY_API_LDFLAGS} ${APPARMOR_LDFLAGS} ${LIBACCOUNTS_LIBRARIES}
45+ ${LIBSIGNON_LIBRARIES} ${Boost_LIBRARIES} ${JSONCPP_LDFLAGS} ${PROCESS_CPP_LDFLAGS}
46+ ${ZMQPPLIB} ${ZMQLIB_LDFLAGS} ${CAPNPLIB} ${KJLIB} ${DLLIB} ${NET_CPP_LDFLAGS} pthread)
47
48 # Standard install paths
49 include(GNUInstallDirs)
50@@ -201,47 +225,6 @@
51 # Version for testing, with all symbols visible
52 set(UNITY_SCOPES_TEST_LIB ${UNITY_SCOPES_LIB}-test)
53
54-find_library(ZMQLIB zmq)
55-if(NOT ZMQLIB)
56- message(FATAL_ERROR "Zmq lib not found.")
57-endif()
58-
59-find_library(ZMQPPLIB zmqpp)
60-if(NOT ZMQPPLIB)
61- message(FATAL_ERROR "Zmqpp lib not found.")
62-endif()
63-
64-find_library(CAPNPLIB capnp)
65-if(NOT CAPNPLIB)
66- message(FATAL_ERROR "Cap'n Proto lib not found.")
67-endif()
68-
69-find_library(KJLIB kj)
70-if(NOT KJLIB)
71- message(FATAL_ERROR "Kj lib not found.")
72-endif()
73-
74-find_library(DLLIB dl)
75-if(NOT DLLIB)
76- message(FATAL_ERROR "Dl lib not found.")
77-endif()
78-
79-
80-# Other libraries we depend on
81-set(OTHER_LIBS
82- ${OTHER_LIBS}
83- ${Boost_LIBRARIES}
84- ${JSONCPP_LDFLAGS}
85- ${PROCESS_CPP_LDFLAGS}
86- ${ZMQPPLIB}
87- ${ZMQLIB}
88- ${CAPNPLIB}
89- ${KJLIB}
90- ${DLLIB}
91- pthread
92- smartscopes
93-)
94-
95 # All the libraries we need to link a normal executable that uses Unity scopes
96 set(LIBS ${UNITY_SCOPES_LIB})
97
98
99=== modified file 'debian/control'
100--- debian/control 2014-10-08 10:58:57 +0000
101+++ debian/control 2015-01-23 12:23:19 +0000
102@@ -22,7 +22,7 @@
103 libzmqpp-dev,
104 liblttng-ust-dev,
105 lttng-tools,
106- qtbase5-dev,
107+ libnet-cpp-dev,
108 libjsoncpp-dev,
109 libaccounts-glib-dev,
110 libsignon-glib-dev,
111
112=== modified file 'include/unity/scopes/OnlineAccountClient.h'
113--- include/unity/scopes/OnlineAccountClient.h 2014-10-10 13:41:06 +0000
114+++ include/unity/scopes/OnlineAccountClient.h 2015-01-23 12:23:19 +0000
115@@ -60,7 +60,7 @@
116 */
117 struct ServiceStatus
118 {
119- uint account_id; ///< A unique ID of the online account parenting this service.
120+ unsigned int account_id; ///< A unique ID of the online account parenting this service.
121 bool service_enabled; ///< True if this service is enabled.
122 bool service_authenticated; ///< True if this service is authenticated.
123 std::string client_id; ///< "ConsumerKey" / "ClientId" OAuth (1 / 2) parameter.
124
125=== modified file 'include/unity/scopes/internal/smartscopes/HttpClientInterface.h'
126--- include/unity/scopes/internal/smartscopes/HttpClientInterface.h 2014-09-22 13:43:00 +0000
127+++ include/unity/scopes/internal/smartscopes/HttpClientInterface.h 2015-01-23 12:23:19 +0000
128@@ -54,7 +54,7 @@
129 virtual ~HttpClientInterface() = default;
130
131 virtual std::shared_ptr<HttpResponseHandle> get(std::string const& request_url,
132- std::function<void(std::string const&)> const& lineData = [](std::string const&) {},
133+ std::function<void(std::string const&)> const& line_data = [](std::string const&) {},
134 HttpHeaders const& headers = HttpHeaders()) = 0;
135
136 virtual std::string to_percent_encoding(std::string const& string) = 0;
137
138=== added file 'include/unity/scopes/internal/smartscopes/HttpClientNetCpp.h'
139--- include/unity/scopes/internal/smartscopes/HttpClientNetCpp.h 1970-01-01 00:00:00 +0000
140+++ include/unity/scopes/internal/smartscopes/HttpClientNetCpp.h 2015-01-23 12:23:19 +0000
141@@ -0,0 +1,78 @@
142+/*
143+ * Copyright (C) 2013 Canonical Ltd
144+ *
145+ * This program is free software: you can redistribute it and/or modify
146+ * it under the terms of the GNU Lesser General Public License version 3 as
147+ * published by the Free Software Foundation.
148+ *
149+ * This program is distributed in the hope that it will be useful,
150+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
151+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152+ * GNU Lesser General Public License for more details.
153+ *
154+ * You should have received a copy of the GNU Lesser General Public License
155+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
156+ *
157+ * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
158+ */
159+
160+#ifndef UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTNETCPP_H
161+#define UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTNETCPP_H
162+
163+#include <unity/scopes/internal/smartscopes/HttpClientInterface.h>
164+
165+#include <memory>
166+#include <thread>
167+
168+namespace core
169+{
170+namespace net
171+{
172+namespace http
173+{
174+class Client;
175+}
176+}
177+}
178+
179+namespace unity
180+{
181+
182+namespace scopes
183+{
184+
185+namespace internal
186+{
187+
188+namespace smartscopes
189+{
190+
191+class HttpClientNetCpp : public HttpClientInterface
192+{
193+public:
194+ explicit HttpClientNetCpp(unsigned int no_reply_timeout);
195+ ~HttpClientNetCpp();
196+
197+ HttpResponseHandle::SPtr get(std::string const& request_url,
198+ std::function<void(std::string const&)> const& line_data = [](std::string const&) {},
199+ HttpHeaders const& headers = HttpHeaders()) override;
200+
201+ std::string to_percent_encoding(std::string const& string) override;
202+
203+private:
204+ void cancel_get(unsigned int session_id) override;
205+
206+ unsigned int no_reply_timeout;
207+ std::shared_ptr<core::net::http::Client> client;
208+ std::thread worker;
209+};
210+
211+} // namespace smartscopes
212+
213+} // namespace internal
214+
215+} // namespace scopes
216+
217+} // namespace unity
218+
219+#endif // UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTNETCPP_H
220
221=== removed file 'include/unity/scopes/internal/smartscopes/HttpClientQt.h'
222--- include/unity/scopes/internal/smartscopes/HttpClientQt.h 2014-09-22 13:43:00 +0000
223+++ include/unity/scopes/internal/smartscopes/HttpClientQt.h 1970-01-01 00:00:00 +0000
224@@ -1,94 +0,0 @@
225-/*
226- * Copyright (C) 2013 Canonical Ltd
227- *
228- * This program is free software: you can redistribute it and/or modify
229- * it under the terms of the GNU Lesser General Public License version 3 as
230- * published by the Free Software Foundation.
231- *
232- * This program is distributed in the hope that it will be useful,
233- * but WITHOUT ANY WARRANTY; without even the implied warranty of
234- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
235- * GNU Lesser General Public License for more details.
236- *
237- * You should have received a copy of the GNU Lesser General Public License
238- * along with this program. If not, see <http://www.gnu.org/licenses/>.
239- *
240- * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
241- */
242-
243-#ifndef UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTQT_H
244-#define UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTQT_H
245-
246-#include <unity/scopes/internal/smartscopes/HttpClientInterface.h>
247-#include <map>
248-
249-class QCoreApplication;
250-
251-namespace unity
252-{
253-
254-namespace scopes
255-{
256-
257-namespace internal
258-{
259-
260-namespace smartscopes
261-{
262-
263-class HttpClientQtThread;
264-
265-class HttpClientQt : public HttpClientInterface
266-{
267-public:
268- explicit HttpClientQt(unsigned int no_reply_timeout);
269- ~HttpClientQt();
270-
271- HttpResponseHandle::SPtr get(std::string const& request_url, std::function<void(std::string const&)> const& lineData = [](std::string const&) {},
272- HttpHeaders const& headers = HttpHeaders()) override;
273-
274- std::string to_percent_encoding(std::string const& string) override;
275-
276-private:
277- void cancel_get(unsigned int session_id) override;
278-
279-private:
280- class HttpSession
281- {
282- public:
283- HttpSession(std::string const& request_url, unsigned int timeout, std::function<void(std::string const&)> const& lineData, HttpHeaders const& headers =
284- HttpHeaders());
285- ~HttpSession();
286-
287- std::future<void> get_future();
288-
289- void cancel_session();
290- void wait_for_session();
291-
292- private:
293- std::promise<void> promise_;
294- std::thread get_thread_;
295- std::unique_ptr<HttpClientQtThread> qt_thread_;
296- std::mutex qt_thread_mutex_;
297- std::promise<void> qt_thread_ready_;
298- };
299-
300-private:
301- unsigned int session_index_;
302- std::map<unsigned int, std::shared_ptr<HttpSession>> sessions_;
303- std::mutex sessions_mutex_;
304-
305- unsigned int const no_reply_timeout_;
306-
307- std::unique_ptr<QCoreApplication> app_;
308-};
309-
310-} // namespace smartscopes
311-
312-} // namespace internal
313-
314-} // namespace scopes
315-
316-} // namespace unity
317-
318-#endif // UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTQT_H
319
320=== removed file 'include/unity/scopes/internal/smartscopes/HttpClientQtThread.h'
321--- include/unity/scopes/internal/smartscopes/HttpClientQtThread.h 2014-09-22 13:43:00 +0000
322+++ include/unity/scopes/internal/smartscopes/HttpClientQtThread.h 1970-01-01 00:00:00 +0000
323@@ -1,103 +0,0 @@
324-/*
325- * Copyright (C) 2013 Canonical Ltd
326- *
327- * This program is free software: you can redistribute it and/or modify
328- * it under the terms of the GNU Lesser General Public License version 3 as
329- * published by the Free Software Foundation.
330- *
331- * This program is distributed in the hope that it will be useful,
332- * but WITHOUT ANY WARRANTY; without even the implied warranty of
333- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
334- * GNU Lesser General Public License for more details.
335- *
336- * You should have received a copy of the GNU Lesser General Public License
337- * along with this program. If not, see <http://www.gnu.org/licenses/>.
338- *
339- * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
340- */
341-
342-#ifndef UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTQTTHREAD_H
343-#define UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTQTTHREAD_H
344-
345-// This hack allows unity-scopes-api to be built with
346-// clang-3.4+ and versions of Qt before v5.1.1.
347-#if QT_VERSION < 0x050101
348- #define register
349-
350- #include <QThread>
351-
352- #define qHash(x,y) qHash(const QUrl &url, unsigned int seed)
353- #include <QUrl>
354- #undef qHash
355-
356- #undef register
357-#else
358- #include <QThread>
359- #include <QUrl>
360-#endif
361-
362-#include <unity/scopes/internal/smartscopes/HttpClientInterface.h>
363-#include <unity/util/NonCopyable.h>
364-
365-#include <mutex>
366-
367-class QNetworkReply;
368-class QNetworkAccessManager;
369-
370-namespace unity
371-{
372-
373-namespace scopes
374-{
375-
376-namespace internal
377-{
378-
379-namespace smartscopes
380-{
381-
382-class Q_DECL_EXPORT HttpClientQtThread : public QThread
383-{
384- Q_OBJECT
385-
386-public:
387- NONCOPYABLE(HttpClientQtThread);
388-
389- HttpClientQtThread(const QUrl& url, unsigned int timeout, std::function<void(std::string const&)> const& lineData, const HttpHeaders& headers =
390- HttpHeaders());
391- ~HttpClientQtThread();
392-
393- bool get_reply(std::string& reply);
394-
395-private:
396- void run();
397-
398-public Q_SLOTS:
399- void cancel();
400- void timeout();
401- void got_reply(QNetworkReply* reply);
402- void dataReady();
403-
404-Q_SIGNALS:
405- void abort();
406-
407-private:
408- QUrl url_;
409- const std::function<void(std::string const&)> lineDataCallback_;
410- HttpHeaders headers_;
411- unsigned int timeout_;
412- std::mutex reply_mutex_;
413-
414- bool success_;
415- std::string reply_;
416-};
417-
418-} // namespace smartscopes
419-
420-} // namespace internal
421-
422-} // namespace scopes
423-
424-} // namespace unity
425-
426-#endif // UNITY_SCOPES_INTERNAL_SMARTSCOPES_HTTPCLIENTQTTHREAD_H
427
428=== modified file 'src/scopes/internal/JsonCppNode.cpp'
429--- src/scopes/internal/JsonCppNode.cpp 2015-01-23 12:23:19 +0000
430+++ src/scopes/internal/JsonCppNode.cpp 2015-01-23 12:23:19 +0000
431@@ -117,7 +117,7 @@
432 return Variant(value.asString());
433 case Json::ValueType::intValue:
434 case Json::ValueType::uintValue:
435- return Variant(value.asInt()); // this can throw std::runtime_error from jsoncpp if uint to int conversion is not possible
436+ return Variant(value.asInt()); // this can throw std::runtime_error from jsoncpp if unsigned int to int conversion is not possible
437 case Json::ValueType::realValue:
438 return Variant(value.asDouble());
439 case Json::ValueType::booleanValue:
440@@ -220,11 +220,11 @@
441 return root_.asInt();
442 }
443
444-uint JsonCppNode::as_uint() const
445+unsigned int JsonCppNode::as_uint() const
446 {
447 if (!root_.isConvertibleTo(Json::uintValue))
448 {
449- throw unity::LogicException("Node does not contain a uint value");
450+ throw unity::LogicException("Node does not contain a unsigned int value");
451 }
452
453 return root_.asUInt();
454@@ -281,7 +281,7 @@
455 return std::make_shared<JsonCppNode>(value_node);
456 }
457
458-JsonNodeInterface::SPtr JsonCppNode::get_node(uint node_index) const
459+JsonNodeInterface::SPtr JsonCppNode::get_node(unsigned int node_index) const
460 {
461 if (root_.type() != Json::arrayValue)
462 {
463
464=== modified file 'src/scopes/internal/RegistryObject.cpp'
465--- src/scopes/internal/RegistryObject.cpp 2014-10-22 15:33:01 +0000
466+++ src/scopes/internal/RegistryObject.cpp 2015-01-23 12:23:19 +0000
467@@ -731,7 +731,7 @@
468 util::ResourcePtr<wordexp_t*, decltype(&wordfree)> free_guard(&exp, wordfree);
469
470 command_args.push_back(exp.we_wordv[0]);
471- for (uint i = 1; i < exp.we_wordc; ++i)
472+ for (unsigned int i = 1; i < exp.we_wordc; ++i)
473 {
474 std::string arg = exp.we_wordv[i];
475 // Replace "%R" placeholders with the runtime config
476
477=== modified file 'src/scopes/internal/smartscopes/CMakeLists.txt'
478--- src/scopes/internal/smartscopes/CMakeLists.txt 2014-08-18 08:50:39 +0000
479+++ src/scopes/internal/smartscopes/CMakeLists.txt 2015-01-23 12:23:19 +0000
480@@ -1,5 +1,7 @@
481 set(SRC
482+ ${CMAKE_CURRENT_SOURCE_DIR}/HttpClientNetCpp.cpp
483 ${CMAKE_CURRENT_SOURCE_DIR}/SmartScope.cpp
484+ ${CMAKE_CURRENT_SOURCE_DIR}/SmartScopesClient.cpp
485 ${CMAKE_CURRENT_SOURCE_DIR}/SSConfig.cpp
486 ${CMAKE_CURRENT_SOURCE_DIR}/SSQueryCtrlObject.cpp
487 ${CMAKE_CURRENT_SOURCE_DIR}/SSQueryObject.cpp
488@@ -7,34 +9,3 @@
489 ${CMAKE_CURRENT_SOURCE_DIR}/SSScopeObject.cpp
490 )
491 set(UNITY_SCOPES_LIB_SRC ${UNITY_SCOPES_LIB_SRC} ${SRC} PARENT_SCOPE)
492-
493-# -- libsmartscopes --
494-
495-set(CMAKE_AUTOMOC ON)
496-set(CMAKE_INCLUDE_CURRENT_DIR ON)
497-
498-find_package(Qt5Core REQUIRED)
499-include_directories(${Qt5Core_INCLUDE_DIRS})
500-
501-add_library(
502- smartscopes STATIC
503-
504- HttpClientQt.cpp
505-
506- ${CMAKE_SOURCE_DIR}/include/unity/scopes/internal/smartscopes/HttpClientQtThread.h
507- HttpClientQtThread.cpp
508-
509- SmartScopesClient.cpp
510-)
511-
512-qt5_use_modules(
513- smartscopes
514-
515- Core
516- Network
517-)
518-
519-target_link_libraries(
520- smartscopes
521- ${UNITY_API_LDFLAGS}
522-)
523
524=== added file 'src/scopes/internal/smartscopes/HttpClientNetCpp.cpp'
525--- src/scopes/internal/smartscopes/HttpClientNetCpp.cpp 1970-01-01 00:00:00 +0000
526+++ src/scopes/internal/smartscopes/HttpClientNetCpp.cpp 2015-01-23 12:23:19 +0000
527@@ -0,0 +1,189 @@
528+/*
529+ * Copyright (C) 2013 Canonical Ltd
530+ *
531+ * This program is free software: you can redistribute it and/or modify
532+ * it under the terms of the GNU Lesser General Public License version 3 as
533+ * published by the Free Software Foundation.
534+ *
535+ * This program is distributed in the hope that it will be useful,
536+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
537+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
538+ * GNU Lesser General Public License for more details.
539+ *
540+ * You should have received a copy of the GNU Lesser General Public License
541+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
542+ *
543+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
544+ */
545+
546+#include <unity/scopes/internal/smartscopes/HttpClientNetCpp.h>
547+
548+#include <unity/UnityExceptions.h>
549+
550+#include <core/net/http/client.h>
551+#include <core/net/http/request.h>
552+#include <core/net/http/response.h>
553+#include <core/net/http/status.h>
554+
555+#include <iostream>
556+#include <unordered_map>
557+
558+namespace net = core::net;
559+namespace http = core::net::http;
560+
561+using namespace unity::scopes::internal::smartscopes;
562+
563+namespace
564+{
565+struct Cancelable
566+{
567+ Cancelable() = default;
568+ Cancelable(const Cancelable&) = delete;
569+ Cancelable& operator=(const Cancelable&) = delete;
570+
571+ void cancel()
572+ {
573+ cancelled.store(true);
574+ }
575+
576+ bool is_cancelled() const
577+ {
578+ return cancelled.load();
579+ }
580+
581+ std::atomic<bool> cancelled{false};
582+};
583+
584+struct CancellationRegistry
585+{
586+ static CancellationRegistry& instance()
587+ {
588+ static CancellationRegistry cr;
589+ return cr;
590+ }
591+
592+ std::pair<unsigned int, std::shared_ptr<Cancelable>> add()
593+ {
594+ auto cancelable = std::make_shared<Cancelable>();
595+ auto id = add(cancelable);
596+
597+ return std::make_pair(id, cancelable);
598+ }
599+
600+ unsigned int add(const std::shared_ptr<Cancelable>& cancelable)
601+ {
602+ std::lock_guard<std::mutex> lg(guard);
603+
604+ unsigned int result{++request_id};
605+
606+ store.insert(std::make_pair(result, cancelable));
607+
608+ return result;
609+ }
610+
611+ void cancel_and_remove_for_id(unsigned int id)
612+ {
613+ std::lock_guard<std::mutex> lg(guard);
614+
615+ auto it = store.find(id);
616+
617+ if (it != store.end())
618+ {
619+ it->second->cancel();
620+ store.erase(it);
621+ }
622+ }
623+
624+ unsigned int request_id{0};
625+ std::mutex guard;
626+ std::unordered_map<unsigned int, std::shared_ptr<Cancelable>> store;
627+};
628+}
629+
630+HttpClientNetCpp::HttpClientNetCpp(unsigned int no_reply_timeout)
631+ : no_reply_timeout{no_reply_timeout},
632+ client{http::make_client()},
633+ worker([this]() { client->run(); })
634+{
635+}
636+
637+HttpClientNetCpp::~HttpClientNetCpp()
638+{
639+ client->stop();
640+
641+ if (worker.joinable())
642+ {
643+ worker.join();
644+ }
645+}
646+
647+HttpResponseHandle::SPtr HttpClientNetCpp::get(std::string const& request_url,
648+ std::function<void(std::string const&)> const& line_data,
649+ HttpHeaders const& headers)
650+{
651+ auto http_config = http::Request::Configuration::from_uri_as_string(request_url);
652+ http::Header http_header;
653+ for (auto const& hdr: headers)
654+ {
655+ http_header.add(hdr.first, hdr.second);
656+ }
657+ http_config.header = http_header;
658+
659+ auto request = client->get(http_config);
660+ request->set_timeout(std::chrono::milliseconds{no_reply_timeout});
661+
662+ auto promise = std::make_shared<std::promise<void>>();
663+ std::shared_future<void> future(promise->get_future());
664+
665+ auto id_and_cancelable = CancellationRegistry::instance().add();
666+
667+ request->async_execute(
668+ http::Request::Handler()
669+ .on_progress([id_and_cancelable](const http::Request::Progress&)
670+ {
671+ return id_and_cancelable.second->is_cancelled() ?
672+ http::Request::Progress::Next::abort_operation :
673+ http::Request::Progress::Next::continue_operation;
674+ })
675+ .on_response([line_data, promise](const http::Response& response)
676+ {
677+ if (response.status != http::Status::ok)
678+ {
679+ std::ostringstream msg;
680+ msg << "HTTP request failed with: " << response.status << std::endl << response.body;
681+ unity::ResourceException e(msg.str());
682+
683+ promise->set_exception(std::make_exception_ptr(e));
684+ }
685+ else
686+ {
687+ std::istringstream in(response.body);
688+ std::string line;
689+ while (std::getline(in, line))
690+ {
691+ line_data(line);
692+ }
693+ promise->set_value();
694+ }
695+ })
696+ .on_error([promise](const net::Error& e)
697+ {
698+ unity::ResourceException re(e.what());
699+ promise->set_exception(std::make_exception_ptr(re));
700+ }));
701+
702+ return std::make_shared<HttpResponseHandle>(
703+ shared_from_this(),
704+ id_and_cancelable.first,
705+ future);
706+}
707+
708+void HttpClientNetCpp::cancel_get(unsigned int id)
709+{
710+ CancellationRegistry::instance().cancel_and_remove_for_id(id);
711+}
712+
713+std::string HttpClientNetCpp::to_percent_encoding(std::string const& string)
714+{
715+ return client->url_escape(string);
716+}
717
718=== removed file 'src/scopes/internal/smartscopes/HttpClientQt.cpp'
719--- src/scopes/internal/smartscopes/HttpClientQt.cpp 2014-09-22 13:43:00 +0000
720+++ src/scopes/internal/smartscopes/HttpClientQt.cpp 1970-01-01 00:00:00 +0000
721@@ -1,147 +0,0 @@
722-/*
723- * Copyright (C) 2013 Canonical Ltd
724- *
725- * This program is free software: you can redistribute it and/or modify
726- * it under the terms of the GNU Lesser General Public License version 3 as
727- * published by the Free Software Foundation.
728- *
729- * This program is distributed in the hope that it will be useful,
730- * but WITHOUT ANY WARRANTY; without even the implied warranty of
731- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
732- * GNU Lesser General Public License for more details.
733- *
734- * You should have received a copy of the GNU Lesser General Public License
735- * along with this program. If not, see <http://www.gnu.org/licenses/>.
736- *
737- * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
738- */
739-
740-#include <unity/scopes/internal/smartscopes/HttpClientQt.h>
741-#include <unity/scopes/internal/smartscopes/HttpClientQtThread.h>
742-#include <unity/UnityExceptions.h>
743-
744-#include <QCoreApplication>
745-#include <QEventLoop>
746-#include <QUrl>
747-#include <QNetworkRequest>
748-#include <QNetworkReply>
749-
750-#include <iostream>
751-
752-using namespace unity::scopes::internal::smartscopes;
753-
754-//-- HttpClientQt
755-
756-HttpClientQt::HttpClientQt(uint no_reply_timeout)
757- : session_index_(0)
758- , no_reply_timeout_(no_reply_timeout)
759- , app_(nullptr)
760-{
761- if (!QCoreApplication::instance())
762- {
763- int argc = 0;
764- app_ = std::unique_ptr<QCoreApplication>(new QCoreApplication(argc, nullptr));
765- }
766-}
767-
768-HttpClientQt::~HttpClientQt()
769-{
770-}
771-
772-HttpResponseHandle::SPtr HttpClientQt::get(std::string const& request_url, std::function<void(std::string const&)> const& lineData,
773- HttpHeaders const& headers)
774-{
775- std::lock_guard<std::mutex> lock(sessions_mutex_);
776-
777- // start new session
778- auto session = std::make_shared<HttpSession>(request_url, no_reply_timeout_, lineData, headers);
779- sessions_[session_index_] = session;
780-
781- return std::make_shared<HttpResponseHandle>(shared_from_this(), session_index_++, session->get_future());
782-}
783-
784-void HttpClientQt::cancel_get(uint session_id)
785-{
786- std::lock_guard<std::mutex> lock(sessions_mutex_);
787-
788- // if session_id in map, cancel it
789- auto it = sessions_.find(session_id);
790- if (it != sessions_.end())
791- {
792- it->second->cancel_session();
793- sessions_.erase(it);
794- }
795-}
796-
797-std::string HttpClientQt::to_percent_encoding(std::string const& string)
798-{
799- return QUrl::toPercentEncoding(string.c_str()).constData();
800-}
801-
802-//-- HttpClientQt::HttpSession
803-
804-HttpClientQt::HttpSession::HttpSession(std::string const& request_url, uint timeout, std::function<void(std::string const&)> const& lineData,
805- HttpHeaders const& headers)
806- : qt_thread_(nullptr)
807-{
808- get_thread_ =
809- std::thread([this, request_url, headers, timeout, lineData]()
810- {
811- QUrl url(request_url.c_str());
812-
813- {
814- std::lock_guard<std::mutex> lock(qt_thread_mutex_);
815- qt_thread_ = std::unique_ptr<HttpClientQtThread>(new HttpClientQtThread(url, timeout, lineData, headers));
816- }
817-
818- QEventLoop loop;
819- QObject::connect(qt_thread_.get(), &HttpClientQtThread::finished, &loop, &QEventLoop::quit);
820-
821- qt_thread_->start();
822- qt_thread_ready_.set_value();
823- loop.exec();
824-
825- std::string reply;
826- bool success = qt_thread_->get_reply(reply);
827-
828- if (!success)
829- {
830- unity::ResourceException e(reply);
831- promise_.set_exception(e.self());
832- }
833- else
834- {
835- promise_.set_value();
836- }
837- });
838-
839- qt_thread_ready_.get_future().wait();
840-}
841-
842-HttpClientQt::HttpSession::~HttpSession()
843-{
844- cancel_session();
845-}
846-
847-std::future<void> HttpClientQt::HttpSession::get_future()
848-{
849- return promise_.get_future();
850-}
851-
852-void HttpClientQt::HttpSession::cancel_session()
853-{
854- {
855- std::lock_guard<std::mutex> lock(qt_thread_mutex_);
856- qt_thread_->cancel();
857- }
858-
859- wait_for_session();
860-}
861-
862-void HttpClientQt::HttpSession::wait_for_session()
863-{
864- if (get_thread_.joinable())
865- {
866- get_thread_.join();
867- }
868-}
869
870=== removed file 'src/scopes/internal/smartscopes/HttpClientQtThread.cpp'
871--- src/scopes/internal/smartscopes/HttpClientQtThread.cpp 2014-09-22 13:43:00 +0000
872+++ src/scopes/internal/smartscopes/HttpClientQtThread.cpp 1970-01-01 00:00:00 +0000
873@@ -1,180 +0,0 @@
874-/*
875- * Copyright (C) 2013 Canonical Ltd
876- *
877- * This program is free software: you can redistribute it and/or modify
878- * it under the terms of the GNU Lesser General Public License version 3 as
879- * published by the Free Software Foundation.
880- *
881- * This program is distributed in the hope that it will be useful,
882- * but WITHOUT ANY WARRANTY; without even the implied warranty of
883- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
884- * GNU Lesser General Public License for more details.
885- *
886- * You should have received a copy of the GNU Lesser General Public License
887- * along with this program. If not, see <http://www.gnu.org/licenses/>.
888- *
889- * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
890- * Pawel Stolowski <pawel.stolowski@canonical.com>
891- */
892-
893-#include "unity/scopes/internal/smartscopes/HttpClientQtThread.h"
894-
895-#include <QNetworkRequest>
896-#include <QNetworkAccessManager>
897-#include <QNetworkReply>
898-#include <QTimer>
899-#include <cassert>
900-#include <iostream>
901-
902-namespace unity
903-{
904-
905-namespace scopes
906-{
907-
908-namespace internal
909-{
910-
911-namespace smartscopes
912-{
913-
914-HttpClientQtThread::HttpClientQtThread(const QUrl& url, uint timeout, std::function<void(std::string const&)> const& lineData, HttpHeaders const& headers)
915- : QThread()
916- , url_(url)
917- , lineDataCallback_(lineData)
918- , headers_(headers)
919- , timeout_(timeout)
920- , success_(false)
921-{
922-}
923-
924-HttpClientQtThread::~HttpClientQtThread()
925-{
926- cancel();
927-
928- wait();
929-}
930-
931-bool HttpClientQtThread::get_reply(std::string& reply)
932-{
933- std::lock_guard<std::mutex> lock(reply_mutex_);
934-
935- reply = reply_;
936- return success_;
937-}
938-
939-void HttpClientQtThread::run()
940-{
941- QNetworkAccessManager* manager = new QNetworkAccessManager();
942-
943- QNetworkRequest request(url_);
944- for (auto const& hdr: headers_)
945- {
946- request.setRawHeader(QString::fromStdString(hdr.first).toUtf8(), QString::fromStdString(hdr.second).toUtf8());
947- }
948-
949- QNetworkReply* reply = manager->get(request);
950- reply->setReadBufferSize(0); // unlimited buffer
951-
952- connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(got_reply(QNetworkReply *)));
953- connect(reply, SIGNAL(readyRead()), this, SLOT(dataReady()));
954- connect(this, &HttpClientQtThread::abort, reply, &QNetworkReply::abort);
955-
956- QTimer timeout;
957- timeout.singleShot(timeout_, this, SLOT(timeout()));
958- QThread::exec(); // enter event loop
959-
960- reply->deleteLater();
961- manager->deleteLater();
962-}
963-
964-void HttpClientQtThread::cancel()
965-{
966- std::lock_guard<std::mutex> lock(reply_mutex_);
967-
968- success_ = false;
969- reply_ = "Request cancelled: " + url_.url().toStdString();
970-
971- emit HttpClientQtThread::abort();
972- quit();
973-}
974-
975-void HttpClientQtThread::timeout()
976-{
977- std::lock_guard<std::mutex> lock(reply_mutex_);
978-
979- success_ = false;
980- reply_ = "Request timed out: " + url_.url().toStdString();
981-
982- emit HttpClientQtThread::abort();
983- quit();
984-}
985-
986-void HttpClientQtThread::dataReady()
987-{
988- QNetworkReply* net_reply = qobject_cast<QNetworkReply*>(sender());
989- if (net_reply)
990- {
991- if (net_reply->canReadLine())
992- {
993- QByteArray data = net_reply->readLine();
994- const std::string replyLine(data.constData(), data.size());
995- lineDataCallback_(replyLine);
996- }
997- }
998-}
999-
1000-void HttpClientQtThread::got_reply(QNetworkReply* reply)
1001-{
1002- std::lock_guard<std::mutex> lock(reply_mutex_);
1003-
1004- if (!reply_.empty())
1005- {
1006- return;
1007- }
1008-
1009- if (!reply)
1010- {
1011- // no reply
1012- success_ = false;
1013- reply_ = "No reply from " + url_.url().toStdString();
1014- }
1015- else if (!reply->isFinished())
1016- {
1017- // incomplete reply
1018- success_ = false;
1019- reply_ = "Incomplete reply from " + url_.url().toStdString();
1020- }
1021- else if (reply->error() != QNetworkReply::NoError)
1022- {
1023- // communication error
1024- success_ = false;
1025- reply_ = reply->errorString().toStdString();
1026- }
1027- else
1028- {
1029- success_ = true;
1030- // read any remaining lines
1031- while (reply->canReadLine())
1032- {
1033- const QByteArray byte_array = reply->readLine();
1034- lineDataCallback_(std::string(byte_array.constData(), byte_array.size()));
1035- }
1036- // there may be data left which is not "\n" terminated
1037- if (reply->bytesAvailable())
1038- {
1039- const QByteArray byte_array = reply->readAll();
1040- lineDataCallback_(std::string(byte_array.constData(), byte_array.size()));
1041- }
1042- }
1043-
1044- quit();
1045-}
1046-
1047-} // namespace smartscopes
1048-
1049-} // namespace internal
1050-
1051-} // namespace scopes
1052-
1053-} // namespace unity
1054
1055=== modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp'
1056--- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-10-22 15:33:01 +0000
1057+++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2015-01-23 12:23:19 +0000
1058@@ -25,7 +25,7 @@
1059 #include <unity/scopes/internal/RuntimeImpl.h>
1060 #include <unity/scopes/internal/ScopeImpl.h>
1061 #include <unity/scopes/internal/ScopeMetadataImpl.h>
1062-#include <unity/scopes/internal/smartscopes/HttpClientQt.h>
1063+#include <unity/scopes/internal/smartscopes/HttpClientNetCpp.h>
1064 #include <unity/scopes/internal/Utils.h>
1065 #include <unity/scopes/ScopeExceptions.h>
1066 #include <unity/UnityExceptions.h>
1067@@ -50,7 +50,7 @@
1068 std::string const& sss_url,
1069 bool caching_enabled)
1070 : ssclient_(std::make_shared<SmartScopesClient>(
1071- std::make_shared<HttpClientQt>(ss_config.http_reply_timeout() * 1000), // need millisecs
1072+ std::make_shared<HttpClientNetCpp>(ss_config.http_reply_timeout() * 1000), // need millisecs
1073 std::make_shared<JsonCppNode>(), sss_url))
1074 , refresh_stopped_(false)
1075 , middleware_(middleware)
1076
1077=== modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp'
1078--- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-12-16 18:33:25 +0000
1079+++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2015-01-23 12:23:19 +0000
1080@@ -60,7 +60,7 @@
1081
1082 //-- SearchHandle
1083
1084-SearchHandle::SearchHandle(uint search_id, SmartScopesClient::SPtr ssc)
1085+SearchHandle::SearchHandle(unsigned int search_id, SmartScopesClient::SPtr ssc)
1086 : search_id_(search_id)
1087 , ssc_(ssc)
1088 {
1089@@ -83,7 +83,7 @@
1090
1091 //-- PreviewHandle
1092
1093-PreviewHandle::PreviewHandle(uint preview_id, SmartScopesClient::SPtr ssc)
1094+PreviewHandle::PreviewHandle(unsigned int preview_id, SmartScopesClient::SPtr ssc)
1095 : preview_id_(preview_id)
1096 , ssc_(ssc)
1097 {
1098@@ -193,8 +193,11 @@
1099 std::cerr << "SmartScopesClient.get_remote_scopes(): failed to read " << partner_file_ << ": " << e.what() << std::endl;
1100 }
1101
1102- HttpResponseHandle::SPtr response = http_client_->get(remote_scopes_uri.str(), [&response_str](std::string const& replyLine) {
1103- response_str += replyLine; // accumulate all reply lines
1104+ std::mutex reponse_mutex;
1105+ HttpResponseHandle::SPtr response = http_client_->get(remote_scopes_uri.str(), [&response_str, &reponse_mutex](std::string const& replyLine)
1106+ {
1107+ std::lock_guard<std::mutex> lock(reponse_mutex);
1108+ response_str += replyLine; // accumulate all reply lines
1109 }, headers);
1110
1111 response->get();
1112@@ -362,7 +365,7 @@
1113 std::string const& locale,
1114 std::string const& country,
1115 std::string const& user_agent_hdr,
1116- uint limit)
1117+ unsigned int limit)
1118 {
1119 std::ostringstream search_uri;
1120 search_uri << base_url << c_search_resource << "?";
1121@@ -405,7 +408,7 @@
1122 }
1123
1124 std::lock_guard<std::mutex> lock(query_results_mutex_);
1125- uint search_id = ++query_counter_;
1126+ unsigned int search_id = ++query_counter_;
1127
1128 std::cout << "SmartScopesClient.search(): GET " << search_uri.str() << std::endl;
1129
1130@@ -416,15 +419,18 @@
1131 headers.push_back(std::make_pair("User-Agent", user_agent_hdr));
1132 }
1133
1134- query_results_[search_id] = http_client_->get(search_uri.str(), [this, handler](std::string const& lineData) {
1135- try
1136- {
1137- parse_line(lineData, handler);
1138- }
1139- catch (std::exception const &e)
1140- {
1141- std::cerr << "Failed to parse: " << e.what() << std::endl;
1142- }
1143+ auto reponse_mutex = std::make_shared<std::mutex>();
1144+ query_results_[search_id] = http_client_->get(search_uri.str(), [this, handler, reponse_mutex](std::string const& line_data)
1145+ {
1146+ std::lock_guard<std::mutex> lock(*reponse_mutex);
1147+ try
1148+ {
1149+ parse_line(line_data, handler);
1150+ }
1151+ catch (std::exception const &e)
1152+ {
1153+ std::cerr << "Failed to parse: " << e.what() << std::endl;
1154+ }
1155 }, headers);
1156
1157 return SearchHandle::UPtr(new SearchHandle(search_id, shared_from_this()));
1158@@ -435,7 +441,7 @@
1159 std::string const& result,
1160 std::string const& session_id,
1161 std::string const& platform,
1162- const uint widgets_api_version,
1163+ const unsigned int widgets_api_version,
1164 VariantMap const& settings,
1165 std::string const& locale,
1166 std::string const& country,
1167@@ -477,18 +483,20 @@
1168 }
1169
1170 std::lock_guard<std::mutex> lock(query_results_mutex_);
1171- uint preview_id = ++query_counter_;
1172+ unsigned int preview_id = ++query_counter_;
1173
1174- std::cout << "SmartScopesClient.preview(): GET " << preview_uri.str() << std::endl;
1175- query_results_[preview_id] = http_client_->get(preview_uri.str(), [this, handler](std::string const& lineData) {
1176- try
1177- {
1178- parse_line(lineData, handler);
1179- }
1180- catch (std::exception const &e)
1181- {
1182- std::cerr << "Failed to parse: " << e.what() << std::endl;
1183- }
1184+ auto reponse_mutex = std::make_shared<std::mutex>();
1185+ query_results_[preview_id] = http_client_->get(preview_uri.str(), [this, handler, reponse_mutex](std::string const& line_data)
1186+ {
1187+ std::lock_guard<std::mutex> lock(*reponse_mutex);
1188+ try
1189+ {
1190+ parse_line(line_data, handler);
1191+ }
1192+ catch (std::exception const &e)
1193+ {
1194+ std::cerr << "Failed to parse: " << e.what() << std::endl;
1195+ }
1196 }, headers);
1197
1198 return PreviewHandle::UPtr(new PreviewHandle(preview_id, shared_from_this()));
1199@@ -622,7 +630,7 @@
1200 }
1201 }
1202
1203-void SmartScopesClient::wait_for_search(uint search_id)
1204+void SmartScopesClient::wait_for_search(unsigned int search_id)
1205 {
1206 try
1207 {
1208@@ -724,7 +732,7 @@
1209 return FilterStateImpl::deserialize(node->to_variant().get_dict());
1210 }
1211
1212-void SmartScopesClient::wait_for_preview(uint preview_id)
1213+void SmartScopesClient::wait_for_preview(unsigned int preview_id)
1214 {
1215 try
1216 {
1217@@ -758,7 +766,7 @@
1218 {
1219 std::vector<std::string> jsons;
1220
1221- uint start_pos = 0;
1222+ unsigned int start_pos = 0;
1223
1224 while (start_pos < json_stream.size())
1225 {
1226@@ -776,7 +784,7 @@
1227 return jsons;
1228 }
1229
1230-void SmartScopesClient::cancel_query(uint query_id)
1231+void SmartScopesClient::cancel_query(unsigned int query_id)
1232 {
1233 std::lock_guard<std::mutex> lock(query_results_mutex_);
1234
1235
1236=== modified file 'test/gtest/scopes/internal/smartscopes/HttpClient/HttpClient_test.cpp'
1237--- test/gtest/scopes/internal/smartscopes/HttpClient/HttpClient_test.cpp 2014-09-03 11:55:23 +0000
1238+++ test/gtest/scopes/internal/smartscopes/HttpClient/HttpClient_test.cpp 2015-01-23 12:23:19 +0000
1239@@ -16,7 +16,7 @@
1240 * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
1241 */
1242
1243-#include <unity/scopes/internal/smartscopes/HttpClientQt.h>
1244+#include <unity/scopes/internal/smartscopes/HttpClientNetCpp.h>
1245 #include <unity/UnityExceptions.h>
1246
1247 #include "../RaiiServer.h"
1248@@ -37,8 +37,8 @@
1249 class HttpClientTest : public Test
1250 {
1251 public:
1252- HttpClientTest(uint no_reply_timeout = 20000)
1253- : http_client_(new HttpClientQt(no_reply_timeout)),
1254+ HttpClientTest(unsigned int no_reply_timeout = 20000)
1255+ : http_client_(new HttpClientNetCpp(no_reply_timeout)),
1256 server_(FAKE_SERVER_PATH)
1257 {
1258 test_url_ = c_test_url + ":" + std::to_string(server_.port_);
1259
1260=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py'
1261--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-12-16 09:55:15 +0000
1262+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2015-01-23 12:23:19 +0000
1263@@ -32,7 +32,10 @@
1264
1265 if outfile != '':
1266 f = open(outfile, 'a')
1267- f.writelines(["%s : %s\n" % (environ['PATH_INFO'], environ['HTTP_USER_AGENT'])])
1268+ if environ.has_key('HTTP_USER_AGENT'):
1269+ f.writelines(["%s : %s\n" % (environ['PATH_INFO'], environ['HTTP_USER_AGENT'])])
1270+ else:
1271+ f.writelines(["%s : \n" % (environ['PATH_INFO'])])
1272
1273 if environ['PATH_INFO'] == '/remote-scopes' and (environ['QUERY_STRING'] == '' or environ['QUERY_STRING'] == 'locale=test_TEST'):
1274 return [remote_scopes_response]
1275
1276=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp'
1277--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-12-16 09:55:54 +0000
1278+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2015-01-23 12:23:19 +0000
1279@@ -16,10 +16,10 @@
1280 * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
1281 */
1282
1283-#include <unity/scopes/OptionSelectorFilter.h>
1284-#include <unity/scopes/internal/smartscopes/HttpClientQt.h>
1285 #include <unity/scopes/internal/JsonCppNode.h>
1286+#include <unity/scopes/internal/smartscopes/HttpClientNetCpp.h>
1287 #include <unity/scopes/internal/smartscopes/SmartScopesClient.h>
1288+#include <unity/scopes/OptionSelectorFilter.h>
1289
1290 #include <unity/UnityExceptions.h>
1291 #include <unity/util/FileIO.h>
1292@@ -45,7 +45,7 @@
1293 {
1294 public:
1295 SmartScopesClientTest()
1296- : http_client_(new HttpClientQt(20000)),
1297+ : http_client_(new HttpClientNetCpp(20000)),
1298 json_node_(new JsonCppNode()),
1299 server_(FAKE_SSS_PATH, FAKE_SSS_LOG)
1300 {
1301
1302=== modified file 'valgrind-suppress'
1303--- valgrind-suppress 2014-10-08 10:58:57 +0000
1304+++ valgrind-suppress 2015-01-23 12:23:19 +0000
1305@@ -68,52 +68,6 @@
1306 obj:/lib/x86_64-linux-gnu/ld-2.18.so
1307 }
1308
1309-# False positives for memory leaks in Qt
1310-
1311-{
1312- QNetworkConfigurationManager
1313- Memcheck:Leak
1314- fun:*alloc
1315- ...
1316- fun:_ZN35QNetworkConfigurationManagerPrivate20updateConfigurationsEv
1317- fun:_ZN35QNetworkConfigurationManagerPrivate10initializeEv
1318-}
1319-
1320-{
1321- QCoreApplication
1322- Memcheck:Leak
1323- fun:realloc
1324- ...
1325- fun:_ZN7QObject5eventEP6QEvent
1326- fun:_ZN16QCoreApplication6notifyEP7QObjectP6QEvent
1327-}
1328-
1329-{
1330- QNetworkAccessManager
1331- Memcheck:Leak
1332- ...
1333- fun:_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
1334- fun:_ZN21QNetworkAccessManager3getERK15QNetworkRequest
1335-}
1336-
1337-{
1338- QNetworkConfigurationManager
1339- Memcheck:Leak
1340- match-leak-kinds: possible
1341- ...
1342- fun:_ZN7QThread5startENS_8PriorityE
1343- fun:_ZN35QNetworkConfigurationManagerPrivate10initializeEv
1344- fun:_Z35qNetworkConfigurationManagerPrivatev
1345-}
1346-
1347-{
1348- QFactoryLoader
1349- Memcheck:Leak
1350- fun:*alloc
1351- ...
1352- fun:_ZNK14QFactoryLoader8instanceEi
1353-}
1354-
1355 # Bogus "invalid read" reports for ::putenv and ::genenv
1356
1357 {

Subscribers

People subscribed via source and target branches

to all changes: