Merge lp:~timeout-scope-team/timeout-scope/timeout_ready_for_publish into lp:timeout
- timeout_ready_for_publish
- Merge into trunk
Proposed by
Victor Tuson Palau
Status: | Needs review |
---|---|
Proposed branch: | lp:~timeout-scope-team/timeout-scope/timeout_ready_for_publish |
Merge into: | lp:timeout |
Diff against target: |
3215 lines (+3000/-0) (has conflicts) 40 files modified
.bzrignore (+14/-0) CMakeLists.txt (+48/-0) COPYING.txt (+674/-0) NOTICE.txt (+16/-0) README.org (+65/-0) apparmor/confined.json (+7/-0) apparmor/unconfined.json (+4/-0) data/CMakeLists.txt (+25/-0) data/renderer/carousel.json (+12/-0) data/renderer/horizontal-list.json (+12/-0) data/renderer/large-grid.json (+12/-0) data/renderer/medium-grid.json (+12/-0) data/renderer/vjournal.json (+15/-0) data/renderer/wide-art.json (+13/-0) data/timeout.ini.in (+13/-0) manifest.json.in (+15/-0) push.sh (+8/-0) run.sh (+24/-0) security.json (+5/-0) src/CMakeLists.txt (+22/-0) src/TimeOut-client.cpp (+372/-0) src/TimeOut-client.h (+101/-0) src/TimeOut-preview.cpp (+413/-0) src/TimeOut-preview.h (+46/-0) src/TimeOut-query.cpp (+491/-0) src/TimeOut-query.h (+69/-0) src/TimeOut-scope.cpp (+62/-0) src/TimeOut-scope.h (+51/-0) src/TimeOut-scope.h.autosave (+50/-0) src/com.canonical.scopes.timeout_timeout.ini (+13/-0) src/com.canonical.scopes.timeout_timeout_automoc.cpp (+2/-0) src/config.h.in (+47/-0) src/timeout.ini (+13/-0) src/timeout_automoc.cpp (+2/-0) test/CMakeLists.txt (+24/-0) test/files/CMakeLists.txt (+1/-0) test/test-timeout-client.cpp (+16/-0) timeout-scope.json (+6/-0) timeout.cbp (+199/-0) timeout.json (+6/-0) Conflict adding file src. Moved existing file to src.moved. |
To merge this branch: | bzr merge lp:~timeout-scope-team/timeout-scope/timeout_ready_for_publish |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michał Karnicki | optional | Pending | |
Review via email: mp+235686@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 16. By Victor Tuson Palau
-
fixed bug with canned queries
Unmerged revisions
- 16. By Victor Tuson Palau
-
fixed bug with canned queries
- 15. By Victor Tuson Palau
-
changes: multi-city surfacing, location awareness, html formating, preview implementations, and confinment
- 14. By Michał Karnicki
-
Comment out main block of TimeOut-client.
- 13. By Michał Karnicki
-
Merge refactored Victor's improvements to image sizes.
- 12. By Michał Karnicki
-
Bump version to 0.4.1.
- 11. By Michał Karnicki
-
Fetch smaller images, 312x208.
- 10. By Michał Karnicki
-
Bump version to 0.4
- 9. By Michał Karnicki
-
Fetch smaller images for better speed.
- 8. By Michał Karnicki
-
Fix background and header foreground colors.
- 7. By Michał Karnicki
-
Remove cache directory.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.bzrignore' | |||
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 | |||
3 | +++ .bzrignore 2014-09-24 10:37:38 +0000 | |||
4 | @@ -0,0 +1,14 @@ | |||
5 | 1 | build | ||
6 | 2 | build/* | ||
7 | 3 | *.click | ||
8 | 4 | click | ||
9 | 5 | click/* | ||
10 | 6 | src/config.h | ||
11 | 7 | manifest.json | ||
12 | 8 | CMakeLists.txt.user | ||
13 | 9 | CMakeCache.txt | ||
14 | 10 | CMakeFiles | ||
15 | 11 | Makefile | ||
16 | 12 | cmake_install.cmake | ||
17 | 13 | install_manifest.txt | ||
18 | 14 | ignore | ||
19 | 0 | 15 | ||
20 | === added file '.excludes' | |||
21 | === added file 'CMakeLists.txt' | |||
22 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
23 | +++ CMakeLists.txt 2014-09-24 10:37:38 +0000 | |||
24 | @@ -0,0 +1,48 @@ | |||
25 | 1 | set(SCOPE_PACKAGE "com.canonical.scopes.timeout") | ||
26 | 2 | set(SCOPE_TITLE "TimeOut") | ||
27 | 3 | set(SCOPE_ICON "icon.png") | ||
28 | 4 | # FYI SCOPE_LOGO currently doesn't work in unity-scope-tool | ||
29 | 5 | set(SCOPE_LOGO "logo.png") | ||
30 | 6 | set(SCOPE_COLOR "color:///#000000") | ||
31 | 7 | set(BG_COLOR "color:///#000000") | ||
32 | 8 | set(FG_COLOR "#FFFFFF") | ||
33 | 9 | set(SCOPE_BG_COLOR "#FFFFFF") | ||
34 | 10 | set(SCOPE_AUTHOR "Canonical") | ||
35 | 11 | set(SCOPE_MAINTAINER "Time Out Group Ltd") | ||
36 | 12 | set(SCOPE_DESC "TimeOut scope") | ||
37 | 13 | set(SCOPE_NAME "timeout") | ||
38 | 14 | |||
39 | 15 | set(ARCH "armhf") | ||
40 | 16 | set(FRAMEWORK "ubuntu-sdk-14.10-dev2") | ||
41 | 17 | |||
42 | 18 | # *** | ||
43 | 19 | |||
44 | 20 | # workaround for bug lp:1340135 | ||
45 | 21 | SET(SCOPE_PATH "/opt/click.ubuntu.com/${SCOPE_PACKAGE}/current") | ||
46 | 22 | |||
47 | 23 | project(timeout CXX) | ||
48 | 24 | cmake_minimum_required(VERSION 2.8.10) | ||
49 | 25 | |||
50 | 26 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall -Wextra") | ||
51 | 27 | set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project") | ||
52 | 28 | |||
53 | 29 | include(GNUInstallDirs) | ||
54 | 30 | include(FindPkgConfig) | ||
55 | 31 | pkg_check_modules(UNITY_SCOPES libunity-scopes>=0.4.0 REQUIRED) | ||
56 | 32 | |||
57 | 33 | set(INI_INSTALLDIR "/${SCOPE_NAME}") | ||
58 | 34 | set(SCOPE_INSTALLDIR "/${SCOPE_NAME}") | ||
59 | 35 | |||
60 | 36 | configure_file( | ||
61 | 37 | "${CMAKE_CURRENT_SOURCE_DIR}/manifest.json.in" | ||
62 | 38 | "${CMAKE_CURRENT_SOURCE_DIR}/manifest.json" | ||
63 | 39 | ) | ||
64 | 40 | |||
65 | 41 | add_subdirectory(src) | ||
66 | 42 | add_subdirectory(data) | ||
67 | 43 | #enable_testing() | ||
68 | 44 | #add_subdirectory(test) | ||
69 | 45 | #add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V --output-on-failure) | ||
70 | 46 | |||
71 | 47 | install(FILES manifest.json DESTINATION "/") | ||
72 | 48 | install(FILES "security.json" DESTINATION "/") | ||
73 | 0 | 49 | ||
74 | === added file 'COPYING.txt' | |||
75 | --- COPYING.txt 1970-01-01 00:00:00 +0000 | |||
76 | +++ COPYING.txt 2014-09-24 10:37:38 +0000 | |||
77 | @@ -0,0 +1,674 @@ | |||
78 | 1 | GNU GENERAL PUBLIC LICENSE | ||
79 | 2 | Version 3, 29 June 2007 | ||
80 | 3 | |||
81 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||
82 | 5 | Everyone is permitted to copy and distribute verbatim copies | ||
83 | 6 | of this license document, but changing it is not allowed. | ||
84 | 7 | |||
85 | 8 | Preamble | ||
86 | 9 | |||
87 | 10 | The GNU General Public License is a free, copyleft license for | ||
88 | 11 | software and other kinds of works. | ||
89 | 12 | |||
90 | 13 | The licenses for most software and other practical works are designed | ||
91 | 14 | to take away your freedom to share and change the works. By contrast, | ||
92 | 15 | the GNU General Public License is intended to guarantee your freedom to | ||
93 | 16 | share and change all versions of a program--to make sure it remains free | ||
94 | 17 | software for all its users. We, the Free Software Foundation, use the | ||
95 | 18 | GNU General Public License for most of our software; it applies also to | ||
96 | 19 | any other work released this way by its authors. You can apply it to | ||
97 | 20 | your programs, too. | ||
98 | 21 | |||
99 | 22 | When we speak of free software, we are referring to freedom, not | ||
100 | 23 | price. Our General Public Licenses are designed to make sure that you | ||
101 | 24 | have the freedom to distribute copies of free software (and charge for | ||
102 | 25 | them if you wish), that you receive source code or can get it if you | ||
103 | 26 | want it, that you can change the software or use pieces of it in new | ||
104 | 27 | free programs, and that you know you can do these things. | ||
105 | 28 | |||
106 | 29 | To protect your rights, we need to prevent others from denying you | ||
107 | 30 | these rights or asking you to surrender the rights. Therefore, you have | ||
108 | 31 | certain responsibilities if you distribute copies of the software, or if | ||
109 | 32 | you modify it: responsibilities to respect the freedom of others. | ||
110 | 33 | |||
111 | 34 | For example, if you distribute copies of such a program, whether | ||
112 | 35 | gratis or for a fee, you must pass on to the recipients the same | ||
113 | 36 | freedoms that you received. You must make sure that they, too, receive | ||
114 | 37 | or can get the source code. And you must show them these terms so they | ||
115 | 38 | know their rights. | ||
116 | 39 | |||
117 | 40 | Developers that use the GNU GPL protect your rights with two steps: | ||
118 | 41 | (1) assert copyright on the software, and (2) offer you this License | ||
119 | 42 | giving you legal permission to copy, distribute and/or modify it. | ||
120 | 43 | |||
121 | 44 | For the developers' and authors' protection, the GPL clearly explains | ||
122 | 45 | that there is no warranty for this free software. For both users' and | ||
123 | 46 | authors' sake, the GPL requires that modified versions be marked as | ||
124 | 47 | changed, so that their problems will not be attributed erroneously to | ||
125 | 48 | authors of previous versions. | ||
126 | 49 | |||
127 | 50 | Some devices are designed to deny users access to install or run | ||
128 | 51 | modified versions of the software inside them, although the manufacturer | ||
129 | 52 | can do so. This is fundamentally incompatible with the aim of | ||
130 | 53 | protecting users' freedom to change the software. The systematic | ||
131 | 54 | pattern of such abuse occurs in the area of products for individuals to | ||
132 | 55 | use, which is precisely where it is most unacceptable. Therefore, we | ||
133 | 56 | have designed this version of the GPL to prohibit the practice for those | ||
134 | 57 | products. If such problems arise substantially in other domains, we | ||
135 | 58 | stand ready to extend this provision to those domains in future versions | ||
136 | 59 | of the GPL, as needed to protect the freedom of users. | ||
137 | 60 | |||
138 | 61 | Finally, every program is threatened constantly by software patents. | ||
139 | 62 | States should not allow patents to restrict development and use of | ||
140 | 63 | software on general-purpose computers, but in those that do, we wish to | ||
141 | 64 | avoid the special danger that patents applied to a free program could | ||
142 | 65 | make it effectively proprietary. To prevent this, the GPL assures that | ||
143 | 66 | patents cannot be used to render the program non-free. | ||
144 | 67 | |||
145 | 68 | The precise terms and conditions for copying, distribution and | ||
146 | 69 | modification follow. | ||
147 | 70 | |||
148 | 71 | TERMS AND CONDITIONS | ||
149 | 72 | |||
150 | 73 | 0. Definitions. | ||
151 | 74 | |||
152 | 75 | "This License" refers to version 3 of the GNU General Public License. | ||
153 | 76 | |||
154 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of | ||
155 | 78 | works, such as semiconductor masks. | ||
156 | 79 | |||
157 | 80 | "The Program" refers to any copyrightable work licensed under this | ||
158 | 81 | License. Each licensee is addressed as "you". "Licensees" and | ||
159 | 82 | "recipients" may be individuals or organizations. | ||
160 | 83 | |||
161 | 84 | To "modify" a work means to copy from or adapt all or part of the work | ||
162 | 85 | in a fashion requiring copyright permission, other than the making of an | ||
163 | 86 | exact copy. The resulting work is called a "modified version" of the | ||
164 | 87 | earlier work or a work "based on" the earlier work. | ||
165 | 88 | |||
166 | 89 | A "covered work" means either the unmodified Program or a work based | ||
167 | 90 | on the Program. | ||
168 | 91 | |||
169 | 92 | To "propagate" a work means to do anything with it that, without | ||
170 | 93 | permission, would make you directly or secondarily liable for | ||
171 | 94 | infringement under applicable copyright law, except executing it on a | ||
172 | 95 | computer or modifying a private copy. Propagation includes copying, | ||
173 | 96 | distribution (with or without modification), making available to the | ||
174 | 97 | public, and in some countries other activities as well. | ||
175 | 98 | |||
176 | 99 | To "convey" a work means any kind of propagation that enables other | ||
177 | 100 | parties to make or receive copies. Mere interaction with a user through | ||
178 | 101 | a computer network, with no transfer of a copy, is not conveying. | ||
179 | 102 | |||
180 | 103 | An interactive user interface displays "Appropriate Legal Notices" | ||
181 | 104 | to the extent that it includes a convenient and prominently visible | ||
182 | 105 | feature that (1) displays an appropriate copyright notice, and (2) | ||
183 | 106 | tells the user that there is no warranty for the work (except to the | ||
184 | 107 | extent that warranties are provided), that licensees may convey the | ||
185 | 108 | work under this License, and how to view a copy of this License. If | ||
186 | 109 | the interface presents a list of user commands or options, such as a | ||
187 | 110 | menu, a prominent item in the list meets this criterion. | ||
188 | 111 | |||
189 | 112 | 1. Source Code. | ||
190 | 113 | |||
191 | 114 | The "source code" for a work means the preferred form of the work | ||
192 | 115 | for making modifications to it. "Object code" means any non-source | ||
193 | 116 | form of a work. | ||
194 | 117 | |||
195 | 118 | A "Standard Interface" means an interface that either is an official | ||
196 | 119 | standard defined by a recognized standards body, or, in the case of | ||
197 | 120 | interfaces specified for a particular programming language, one that | ||
198 | 121 | is widely used among developers working in that language. | ||
199 | 122 | |||
200 | 123 | The "System Libraries" of an executable work include anything, other | ||
201 | 124 | than the work as a whole, that (a) is included in the normal form of | ||
202 | 125 | packaging a Major Component, but which is not part of that Major | ||
203 | 126 | Component, and (b) serves only to enable use of the work with that | ||
204 | 127 | Major Component, or to implement a Standard Interface for which an | ||
205 | 128 | implementation is available to the public in source code form. A | ||
206 | 129 | "Major Component", in this context, means a major essential component | ||
207 | 130 | (kernel, window system, and so on) of the specific operating system | ||
208 | 131 | (if any) on which the executable work runs, or a compiler used to | ||
209 | 132 | produce the work, or an object code interpreter used to run it. | ||
210 | 133 | |||
211 | 134 | The "Corresponding Source" for a work in object code form means all | ||
212 | 135 | the source code needed to generate, install, and (for an executable | ||
213 | 136 | work) run the object code and to modify the work, including scripts to | ||
214 | 137 | control those activities. However, it does not include the work's | ||
215 | 138 | System Libraries, or general-purpose tools or generally available free | ||
216 | 139 | programs which are used unmodified in performing those activities but | ||
217 | 140 | which are not part of the work. For example, Corresponding Source | ||
218 | 141 | includes interface definition files associated with source files for | ||
219 | 142 | the work, and the source code for shared libraries and dynamically | ||
220 | 143 | linked subprograms that the work is specifically designed to require, | ||
221 | 144 | such as by intimate data communication or control flow between those | ||
222 | 145 | subprograms and other parts of the work. | ||
223 | 146 | |||
224 | 147 | The Corresponding Source need not include anything that users | ||
225 | 148 | can regenerate automatically from other parts of the Corresponding | ||
226 | 149 | Source. | ||
227 | 150 | |||
228 | 151 | The Corresponding Source for a work in source code form is that | ||
229 | 152 | same work. | ||
230 | 153 | |||
231 | 154 | 2. Basic Permissions. | ||
232 | 155 | |||
233 | 156 | All rights granted under this License are granted for the term of | ||
234 | 157 | copyright on the Program, and are irrevocable provided the stated | ||
235 | 158 | conditions are met. This License explicitly affirms your unlimited | ||
236 | 159 | permission to run the unmodified Program. The output from running a | ||
237 | 160 | covered work is covered by this License only if the output, given its | ||
238 | 161 | content, constitutes a covered work. This License acknowledges your | ||
239 | 162 | rights of fair use or other equivalent, as provided by copyright law. | ||
240 | 163 | |||
241 | 164 | You may make, run and propagate covered works that you do not | ||
242 | 165 | convey, without conditions so long as your license otherwise remains | ||
243 | 166 | in force. You may convey covered works to others for the sole purpose | ||
244 | 167 | of having them make modifications exclusively for you, or provide you | ||
245 | 168 | with facilities for running those works, provided that you comply with | ||
246 | 169 | the terms of this License in conveying all material for which you do | ||
247 | 170 | not control copyright. Those thus making or running the covered works | ||
248 | 171 | for you must do so exclusively on your behalf, under your direction | ||
249 | 172 | and control, on terms that prohibit them from making any copies of | ||
250 | 173 | your copyrighted material outside their relationship with you. | ||
251 | 174 | |||
252 | 175 | Conveying under any other circumstances is permitted solely under | ||
253 | 176 | the conditions stated below. Sublicensing is not allowed; section 10 | ||
254 | 177 | makes it unnecessary. | ||
255 | 178 | |||
256 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. | ||
257 | 180 | |||
258 | 181 | No covered work shall be deemed part of an effective technological | ||
259 | 182 | measure under any applicable law fulfilling obligations under article | ||
260 | 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or | ||
261 | 184 | similar laws prohibiting or restricting circumvention of such | ||
262 | 185 | measures. | ||
263 | 186 | |||
264 | 187 | When you convey a covered work, you waive any legal power to forbid | ||
265 | 188 | circumvention of technological measures to the extent such circumvention | ||
266 | 189 | is effected by exercising rights under this License with respect to | ||
267 | 190 | the covered work, and you disclaim any intention to limit operation or | ||
268 | 191 | modification of the work as a means of enforcing, against the work's | ||
269 | 192 | users, your or third parties' legal rights to forbid circumvention of | ||
270 | 193 | technological measures. | ||
271 | 194 | |||
272 | 195 | 4. Conveying Verbatim Copies. | ||
273 | 196 | |||
274 | 197 | You may convey verbatim copies of the Program's source code as you | ||
275 | 198 | receive it, in any medium, provided that you conspicuously and | ||
276 | 199 | appropriately publish on each copy an appropriate copyright notice; | ||
277 | 200 | keep intact all notices stating that this License and any | ||
278 | 201 | non-permissive terms added in accord with section 7 apply to the code; | ||
279 | 202 | keep intact all notices of the absence of any warranty; and give all | ||
280 | 203 | recipients a copy of this License along with the Program. | ||
281 | 204 | |||
282 | 205 | You may charge any price or no price for each copy that you convey, | ||
283 | 206 | and you may offer support or warranty protection for a fee. | ||
284 | 207 | |||
285 | 208 | 5. Conveying Modified Source Versions. | ||
286 | 209 | |||
287 | 210 | You may convey a work based on the Program, or the modifications to | ||
288 | 211 | produce it from the Program, in the form of source code under the | ||
289 | 212 | terms of section 4, provided that you also meet all of these conditions: | ||
290 | 213 | |||
291 | 214 | a) The work must carry prominent notices stating that you modified | ||
292 | 215 | it, and giving a relevant date. | ||
293 | 216 | |||
294 | 217 | b) The work must carry prominent notices stating that it is | ||
295 | 218 | released under this License and any conditions added under section | ||
296 | 219 | 7. This requirement modifies the requirement in section 4 to | ||
297 | 220 | "keep intact all notices". | ||
298 | 221 | |||
299 | 222 | c) You must license the entire work, as a whole, under this | ||
300 | 223 | License to anyone who comes into possession of a copy. This | ||
301 | 224 | License will therefore apply, along with any applicable section 7 | ||
302 | 225 | additional terms, to the whole of the work, and all its parts, | ||
303 | 226 | regardless of how they are packaged. This License gives no | ||
304 | 227 | permission to license the work in any other way, but it does not | ||
305 | 228 | invalidate such permission if you have separately received it. | ||
306 | 229 | |||
307 | 230 | d) If the work has interactive user interfaces, each must display | ||
308 | 231 | Appropriate Legal Notices; however, if the Program has interactive | ||
309 | 232 | interfaces that do not display Appropriate Legal Notices, your | ||
310 | 233 | work need not make them do so. | ||
311 | 234 | |||
312 | 235 | A compilation of a covered work with other separate and independent | ||
313 | 236 | works, which are not by their nature extensions of the covered work, | ||
314 | 237 | and which are not combined with it such as to form a larger program, | ||
315 | 238 | in or on a volume of a storage or distribution medium, is called an | ||
316 | 239 | "aggregate" if the compilation and its resulting copyright are not | ||
317 | 240 | used to limit the access or legal rights of the compilation's users | ||
318 | 241 | beyond what the individual works permit. Inclusion of a covered work | ||
319 | 242 | in an aggregate does not cause this License to apply to the other | ||
320 | 243 | parts of the aggregate. | ||
321 | 244 | |||
322 | 245 | 6. Conveying Non-Source Forms. | ||
323 | 246 | |||
324 | 247 | You may convey a covered work in object code form under the terms | ||
325 | 248 | of sections 4 and 5, provided that you also convey the | ||
326 | 249 | machine-readable Corresponding Source under the terms of this License, | ||
327 | 250 | in one of these ways: | ||
328 | 251 | |||
329 | 252 | a) Convey the object code in, or embodied in, a physical product | ||
330 | 253 | (including a physical distribution medium), accompanied by the | ||
331 | 254 | Corresponding Source fixed on a durable physical medium | ||
332 | 255 | customarily used for software interchange. | ||
333 | 256 | |||
334 | 257 | b) Convey the object code in, or embodied in, a physical product | ||
335 | 258 | (including a physical distribution medium), accompanied by a | ||
336 | 259 | written offer, valid for at least three years and valid for as | ||
337 | 260 | long as you offer spare parts or customer support for that product | ||
338 | 261 | model, to give anyone who possesses the object code either (1) a | ||
339 | 262 | copy of the Corresponding Source for all the software in the | ||
340 | 263 | product that is covered by this License, on a durable physical | ||
341 | 264 | medium customarily used for software interchange, for a price no | ||
342 | 265 | more than your reasonable cost of physically performing this | ||
343 | 266 | conveying of source, or (2) access to copy the | ||
344 | 267 | Corresponding Source from a network server at no charge. | ||
345 | 268 | |||
346 | 269 | c) Convey individual copies of the object code with a copy of the | ||
347 | 270 | written offer to provide the Corresponding Source. This | ||
348 | 271 | alternative is allowed only occasionally and noncommercially, and | ||
349 | 272 | only if you received the object code with such an offer, in accord | ||
350 | 273 | with subsection 6b. | ||
351 | 274 | |||
352 | 275 | d) Convey the object code by offering access from a designated | ||
353 | 276 | place (gratis or for a charge), and offer equivalent access to the | ||
354 | 277 | Corresponding Source in the same way through the same place at no | ||
355 | 278 | further charge. You need not require recipients to copy the | ||
356 | 279 | Corresponding Source along with the object code. If the place to | ||
357 | 280 | copy the object code is a network server, the Corresponding Source | ||
358 | 281 | may be on a different server (operated by you or a third party) | ||
359 | 282 | that supports equivalent copying facilities, provided you maintain | ||
360 | 283 | clear directions next to the object code saying where to find the | ||
361 | 284 | Corresponding Source. Regardless of what server hosts the | ||
362 | 285 | Corresponding Source, you remain obligated to ensure that it is | ||
363 | 286 | available for as long as needed to satisfy these requirements. | ||
364 | 287 | |||
365 | 288 | e) Convey the object code using peer-to-peer transmission, provided | ||
366 | 289 | you inform other peers where the object code and Corresponding | ||
367 | 290 | Source of the work are being offered to the general public at no | ||
368 | 291 | charge under subsection 6d. | ||
369 | 292 | |||
370 | 293 | A separable portion of the object code, whose source code is excluded | ||
371 | 294 | from the Corresponding Source as a System Library, need not be | ||
372 | 295 | included in conveying the object code work. | ||
373 | 296 | |||
374 | 297 | A "User Product" is either (1) a "consumer product", which means any | ||
375 | 298 | tangible personal property which is normally used for personal, family, | ||
376 | 299 | or household purposes, or (2) anything designed or sold for incorporation | ||
377 | 300 | into a dwelling. In determining whether a product is a consumer product, | ||
378 | 301 | doubtful cases shall be resolved in favor of coverage. For a particular | ||
379 | 302 | product received by a particular user, "normally used" refers to a | ||
380 | 303 | typical or common use of that class of product, regardless of the status | ||
381 | 304 | of the particular user or of the way in which the particular user | ||
382 | 305 | actually uses, or expects or is expected to use, the product. A product | ||
383 | 306 | is a consumer product regardless of whether the product has substantial | ||
384 | 307 | commercial, industrial or non-consumer uses, unless such uses represent | ||
385 | 308 | the only significant mode of use of the product. | ||
386 | 309 | |||
387 | 310 | "Installation Information" for a User Product means any methods, | ||
388 | 311 | procedures, authorization keys, or other information required to install | ||
389 | 312 | and execute modified versions of a covered work in that User Product from | ||
390 | 313 | a modified version of its Corresponding Source. The information must | ||
391 | 314 | suffice to ensure that the continued functioning of the modified object | ||
392 | 315 | code is in no case prevented or interfered with solely because | ||
393 | 316 | modification has been made. | ||
394 | 317 | |||
395 | 318 | If you convey an object code work under this section in, or with, or | ||
396 | 319 | specifically for use in, a User Product, and the conveying occurs as | ||
397 | 320 | part of a transaction in which the right of possession and use of the | ||
398 | 321 | User Product is transferred to the recipient in perpetuity or for a | ||
399 | 322 | fixed term (regardless of how the transaction is characterized), the | ||
400 | 323 | Corresponding Source conveyed under this section must be accompanied | ||
401 | 324 | by the Installation Information. But this requirement does not apply | ||
402 | 325 | if neither you nor any third party retains the ability to install | ||
403 | 326 | modified object code on the User Product (for example, the work has | ||
404 | 327 | been installed in ROM). | ||
405 | 328 | |||
406 | 329 | The requirement to provide Installation Information does not include a | ||
407 | 330 | requirement to continue to provide support service, warranty, or updates | ||
408 | 331 | for a work that has been modified or installed by the recipient, or for | ||
409 | 332 | the User Product in which it has been modified or installed. Access to a | ||
410 | 333 | network may be denied when the modification itself materially and | ||
411 | 334 | adversely affects the operation of the network or violates the rules and | ||
412 | 335 | protocols for communication across the network. | ||
413 | 336 | |||
414 | 337 | Corresponding Source conveyed, and Installation Information provided, | ||
415 | 338 | in accord with this section must be in a format that is publicly | ||
416 | 339 | documented (and with an implementation available to the public in | ||
417 | 340 | source code form), and must require no special password or key for | ||
418 | 341 | unpacking, reading or copying. | ||
419 | 342 | |||
420 | 343 | 7. Additional Terms. | ||
421 | 344 | |||
422 | 345 | "Additional permissions" are terms that supplement the terms of this | ||
423 | 346 | License by making exceptions from one or more of its conditions. | ||
424 | 347 | Additional permissions that are applicable to the entire Program shall | ||
425 | 348 | be treated as though they were included in this License, to the extent | ||
426 | 349 | that they are valid under applicable law. If additional permissions | ||
427 | 350 | apply only to part of the Program, that part may be used separately | ||
428 | 351 | under those permissions, but the entire Program remains governed by | ||
429 | 352 | this License without regard to the additional permissions. | ||
430 | 353 | |||
431 | 354 | When you convey a copy of a covered work, you may at your option | ||
432 | 355 | remove any additional permissions from that copy, or from any part of | ||
433 | 356 | it. (Additional permissions may be written to require their own | ||
434 | 357 | removal in certain cases when you modify the work.) You may place | ||
435 | 358 | additional permissions on material, added by you to a covered work, | ||
436 | 359 | for which you have or can give appropriate copyright permission. | ||
437 | 360 | |||
438 | 361 | Notwithstanding any other provision of this License, for material you | ||
439 | 362 | add to a covered work, you may (if authorized by the copyright holders of | ||
440 | 363 | that material) supplement the terms of this License with terms: | ||
441 | 364 | |||
442 | 365 | a) Disclaiming warranty or limiting liability differently from the | ||
443 | 366 | terms of sections 15 and 16 of this License; or | ||
444 | 367 | |||
445 | 368 | b) Requiring preservation of specified reasonable legal notices or | ||
446 | 369 | author attributions in that material or in the Appropriate Legal | ||
447 | 370 | Notices displayed by works containing it; or | ||
448 | 371 | |||
449 | 372 | c) Prohibiting misrepresentation of the origin of that material, or | ||
450 | 373 | requiring that modified versions of such material be marked in | ||
451 | 374 | reasonable ways as different from the original version; or | ||
452 | 375 | |||
453 | 376 | d) Limiting the use for publicity purposes of names of licensors or | ||
454 | 377 | authors of the material; or | ||
455 | 378 | |||
456 | 379 | e) Declining to grant rights under trademark law for use of some | ||
457 | 380 | trade names, trademarks, or service marks; or | ||
458 | 381 | |||
459 | 382 | f) Requiring indemnification of licensors and authors of that | ||
460 | 383 | material by anyone who conveys the material (or modified versions of | ||
461 | 384 | it) with contractual assumptions of liability to the recipient, for | ||
462 | 385 | any liability that these contractual assumptions directly impose on | ||
463 | 386 | those licensors and authors. | ||
464 | 387 | |||
465 | 388 | All other non-permissive additional terms are considered "further | ||
466 | 389 | restrictions" within the meaning of section 10. If the Program as you | ||
467 | 390 | received it, or any part of it, contains a notice stating that it is | ||
468 | 391 | governed by this License along with a term that is a further | ||
469 | 392 | restriction, you may remove that term. If a license document contains | ||
470 | 393 | a further restriction but permits relicensing or conveying under this | ||
471 | 394 | License, you may add to a covered work material governed by the terms | ||
472 | 395 | of that license document, provided that the further restriction does | ||
473 | 396 | not survive such relicensing or conveying. | ||
474 | 397 | |||
475 | 398 | If you add terms to a covered work in accord with this section, you | ||
476 | 399 | must place, in the relevant source files, a statement of the | ||
477 | 400 | additional terms that apply to those files, or a notice indicating | ||
478 | 401 | where to find the applicable terms. | ||
479 | 402 | |||
480 | 403 | Additional terms, permissive or non-permissive, may be stated in the | ||
481 | 404 | form of a separately written license, or stated as exceptions; | ||
482 | 405 | the above requirements apply either way. | ||
483 | 406 | |||
484 | 407 | 8. Termination. | ||
485 | 408 | |||
486 | 409 | You may not propagate or modify a covered work except as expressly | ||
487 | 410 | provided under this License. Any attempt otherwise to propagate or | ||
488 | 411 | modify it is void, and will automatically terminate your rights under | ||
489 | 412 | this License (including any patent licenses granted under the third | ||
490 | 413 | paragraph of section 11). | ||
491 | 414 | |||
492 | 415 | However, if you cease all violation of this License, then your | ||
493 | 416 | license from a particular copyright holder is reinstated (a) | ||
494 | 417 | provisionally, unless and until the copyright holder explicitly and | ||
495 | 418 | finally terminates your license, and (b) permanently, if the copyright | ||
496 | 419 | holder fails to notify you of the violation by some reasonable means | ||
497 | 420 | prior to 60 days after the cessation. | ||
498 | 421 | |||
499 | 422 | Moreover, your license from a particular copyright holder is | ||
500 | 423 | reinstated permanently if the copyright holder notifies you of the | ||
501 | 424 | violation by some reasonable means, this is the first time you have | ||
502 | 425 | received notice of violation of this License (for any work) from that | ||
503 | 426 | copyright holder, and you cure the violation prior to 30 days after | ||
504 | 427 | your receipt of the notice. | ||
505 | 428 | |||
506 | 429 | Termination of your rights under this section does not terminate the | ||
507 | 430 | licenses of parties who have received copies or rights from you under | ||
508 | 431 | this License. If your rights have been terminated and not permanently | ||
509 | 432 | reinstated, you do not qualify to receive new licenses for the same | ||
510 | 433 | material under section 10. | ||
511 | 434 | |||
512 | 435 | 9. Acceptance Not Required for Having Copies. | ||
513 | 436 | |||
514 | 437 | You are not required to accept this License in order to receive or | ||
515 | 438 | run a copy of the Program. Ancillary propagation of a covered work | ||
516 | 439 | occurring solely as a consequence of using peer-to-peer transmission | ||
517 | 440 | to receive a copy likewise does not require acceptance. However, | ||
518 | 441 | nothing other than this License grants you permission to propagate or | ||
519 | 442 | modify any covered work. These actions infringe copyright if you do | ||
520 | 443 | not accept this License. Therefore, by modifying or propagating a | ||
521 | 444 | covered work, you indicate your acceptance of this License to do so. | ||
522 | 445 | |||
523 | 446 | 10. Automatic Licensing of Downstream Recipients. | ||
524 | 447 | |||
525 | 448 | Each time you convey a covered work, the recipient automatically | ||
526 | 449 | receives a license from the original licensors, to run, modify and | ||
527 | 450 | propagate that work, subject to this License. You are not responsible | ||
528 | 451 | for enforcing compliance by third parties with this License. | ||
529 | 452 | |||
530 | 453 | An "entity transaction" is a transaction transferring control of an | ||
531 | 454 | organization, or substantially all assets of one, or subdividing an | ||
532 | 455 | organization, or merging organizations. If propagation of a covered | ||
533 | 456 | work results from an entity transaction, each party to that | ||
534 | 457 | transaction who receives a copy of the work also receives whatever | ||
535 | 458 | licenses to the work the party's predecessor in interest had or could | ||
536 | 459 | give under the previous paragraph, plus a right to possession of the | ||
537 | 460 | Corresponding Source of the work from the predecessor in interest, if | ||
538 | 461 | the predecessor has it or can get it with reasonable efforts. | ||
539 | 462 | |||
540 | 463 | You may not impose any further restrictions on the exercise of the | ||
541 | 464 | rights granted or affirmed under this License. For example, you may | ||
542 | 465 | not impose a license fee, royalty, or other charge for exercise of | ||
543 | 466 | rights granted under this License, and you may not initiate litigation | ||
544 | 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that | ||
545 | 468 | any patent claim is infringed by making, using, selling, offering for | ||
546 | 469 | sale, or importing the Program or any portion of it. | ||
547 | 470 | |||
548 | 471 | 11. Patents. | ||
549 | 472 | |||
550 | 473 | A "contributor" is a copyright holder who authorizes use under this | ||
551 | 474 | License of the Program or a work on which the Program is based. The | ||
552 | 475 | work thus licensed is called the contributor's "contributor version". | ||
553 | 476 | |||
554 | 477 | A contributor's "essential patent claims" are all patent claims | ||
555 | 478 | owned or controlled by the contributor, whether already acquired or | ||
556 | 479 | hereafter acquired, that would be infringed by some manner, permitted | ||
557 | 480 | by this License, of making, using, or selling its contributor version, | ||
558 | 481 | but do not include claims that would be infringed only as a | ||
559 | 482 | consequence of further modification of the contributor version. For | ||
560 | 483 | purposes of this definition, "control" includes the right to grant | ||
561 | 484 | patent sublicenses in a manner consistent with the requirements of | ||
562 | 485 | this License. | ||
563 | 486 | |||
564 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free | ||
565 | 488 | patent license under the contributor's essential patent claims, to | ||
566 | 489 | make, use, sell, offer for sale, import and otherwise run, modify and | ||
567 | 490 | propagate the contents of its contributor version. | ||
568 | 491 | |||
569 | 492 | In the following three paragraphs, a "patent license" is any express | ||
570 | 493 | agreement or commitment, however denominated, not to enforce a patent | ||
571 | 494 | (such as an express permission to practice a patent or covenant not to | ||
572 | 495 | sue for patent infringement). To "grant" such a patent license to a | ||
573 | 496 | party means to make such an agreement or commitment not to enforce a | ||
574 | 497 | patent against the party. | ||
575 | 498 | |||
576 | 499 | If you convey a covered work, knowingly relying on a patent license, | ||
577 | 500 | and the Corresponding Source of the work is not available for anyone | ||
578 | 501 | to copy, free of charge and under the terms of this License, through a | ||
579 | 502 | publicly available network server or other readily accessible means, | ||
580 | 503 | then you must either (1) cause the Corresponding Source to be so | ||
581 | 504 | available, or (2) arrange to deprive yourself of the benefit of the | ||
582 | 505 | patent license for this particular work, or (3) arrange, in a manner | ||
583 | 506 | consistent with the requirements of this License, to extend the patent | ||
584 | 507 | license to downstream recipients. "Knowingly relying" means you have | ||
585 | 508 | actual knowledge that, but for the patent license, your conveying the | ||
586 | 509 | covered work in a country, or your recipient's use of the covered work | ||
587 | 510 | in a country, would infringe one or more identifiable patents in that | ||
588 | 511 | country that you have reason to believe are valid. | ||
589 | 512 | |||
590 | 513 | If, pursuant to or in connection with a single transaction or | ||
591 | 514 | arrangement, you convey, or propagate by procuring conveyance of, a | ||
592 | 515 | covered work, and grant a patent license to some of the parties | ||
593 | 516 | receiving the covered work authorizing them to use, propagate, modify | ||
594 | 517 | or convey a specific copy of the covered work, then the patent license | ||
595 | 518 | you grant is automatically extended to all recipients of the covered | ||
596 | 519 | work and works based on it. | ||
597 | 520 | |||
598 | 521 | A patent license is "discriminatory" if it does not include within | ||
599 | 522 | the scope of its coverage, prohibits the exercise of, or is | ||
600 | 523 | conditioned on the non-exercise of one or more of the rights that are | ||
601 | 524 | specifically granted under this License. You may not convey a covered | ||
602 | 525 | work if you are a party to an arrangement with a third party that is | ||
603 | 526 | in the business of distributing software, under which you make payment | ||
604 | 527 | to the third party based on the extent of your activity of conveying | ||
605 | 528 | the work, and under which the third party grants, to any of the | ||
606 | 529 | parties who would receive the covered work from you, a discriminatory | ||
607 | 530 | patent license (a) in connection with copies of the covered work | ||
608 | 531 | conveyed by you (or copies made from those copies), or (b) primarily | ||
609 | 532 | for and in connection with specific products or compilations that | ||
610 | 533 | contain the covered work, unless you entered into that arrangement, | ||
611 | 534 | or that patent license was granted, prior to 28 March 2007. | ||
612 | 535 | |||
613 | 536 | Nothing in this License shall be construed as excluding or limiting | ||
614 | 537 | any implied license or other defenses to infringement that may | ||
615 | 538 | otherwise be available to you under applicable patent law. | ||
616 | 539 | |||
617 | 540 | 12. No Surrender of Others' Freedom. | ||
618 | 541 | |||
619 | 542 | If conditions are imposed on you (whether by court order, agreement or | ||
620 | 543 | otherwise) that contradict the conditions of this License, they do not | ||
621 | 544 | excuse you from the conditions of this License. If you cannot convey a | ||
622 | 545 | covered work so as to satisfy simultaneously your obligations under this | ||
623 | 546 | License and any other pertinent obligations, then as a consequence you may | ||
624 | 547 | not convey it at all. For example, if you agree to terms that obligate you | ||
625 | 548 | to collect a royalty for further conveying from those to whom you convey | ||
626 | 549 | the Program, the only way you could satisfy both those terms and this | ||
627 | 550 | License would be to refrain entirely from conveying the Program. | ||
628 | 551 | |||
629 | 552 | 13. Use with the GNU Affero General Public License. | ||
630 | 553 | |||
631 | 554 | Notwithstanding any other provision of this License, you have | ||
632 | 555 | permission to link or combine any covered work with a work licensed | ||
633 | 556 | under version 3 of the GNU Affero General Public License into a single | ||
634 | 557 | combined work, and to convey the resulting work. The terms of this | ||
635 | 558 | License will continue to apply to the part which is the covered work, | ||
636 | 559 | but the special requirements of the GNU Affero General Public License, | ||
637 | 560 | section 13, concerning interaction through a network will apply to the | ||
638 | 561 | combination as such. | ||
639 | 562 | |||
640 | 563 | 14. Revised Versions of this License. | ||
641 | 564 | |||
642 | 565 | The Free Software Foundation may publish revised and/or new versions of | ||
643 | 566 | the GNU General Public License from time to time. Such new versions will | ||
644 | 567 | be similar in spirit to the present version, but may differ in detail to | ||
645 | 568 | address new problems or concerns. | ||
646 | 569 | |||
647 | 570 | Each version is given a distinguishing version number. If the | ||
648 | 571 | Program specifies that a certain numbered version of the GNU General | ||
649 | 572 | Public License "or any later version" applies to it, you have the | ||
650 | 573 | option of following the terms and conditions either of that numbered | ||
651 | 574 | version or of any later version published by the Free Software | ||
652 | 575 | Foundation. If the Program does not specify a version number of the | ||
653 | 576 | GNU General Public License, you may choose any version ever published | ||
654 | 577 | by the Free Software Foundation. | ||
655 | 578 | |||
656 | 579 | If the Program specifies that a proxy can decide which future | ||
657 | 580 | versions of the GNU General Public License can be used, that proxy's | ||
658 | 581 | public statement of acceptance of a version permanently authorizes you | ||
659 | 582 | to choose that version for the Program. | ||
660 | 583 | |||
661 | 584 | Later license versions may give you additional or different | ||
662 | 585 | permissions. However, no additional obligations are imposed on any | ||
663 | 586 | author or copyright holder as a result of your choosing to follow a | ||
664 | 587 | later version. | ||
665 | 588 | |||
666 | 589 | 15. Disclaimer of Warranty. | ||
667 | 590 | |||
668 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY | ||
669 | 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT | ||
670 | 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY | ||
671 | 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, | ||
672 | 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
673 | 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM | ||
674 | 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF | ||
675 | 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | ||
676 | 599 | |||
677 | 600 | 16. Limitation of Liability. | ||
678 | 601 | |||
679 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
680 | 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS | ||
681 | 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY | ||
682 | 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE | ||
683 | 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF | ||
684 | 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD | ||
685 | 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), | ||
686 | 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
687 | 610 | SUCH DAMAGES. | ||
688 | 611 | |||
689 | 612 | 17. Interpretation of Sections 15 and 16. | ||
690 | 613 | |||
691 | 614 | If the disclaimer of warranty and limitation of liability provided | ||
692 | 615 | above cannot be given local legal effect according to their terms, | ||
693 | 616 | reviewing courts shall apply local law that most closely approximates | ||
694 | 617 | an absolute waiver of all civil liability in connection with the | ||
695 | 618 | Program, unless a warranty or assumption of liability accompanies a | ||
696 | 619 | copy of the Program in return for a fee. | ||
697 | 620 | |||
698 | 621 | END OF TERMS AND CONDITIONS | ||
699 | 622 | |||
700 | 623 | How to Apply These Terms to Your New Programs | ||
701 | 624 | |||
702 | 625 | If you develop a new program, and you want it to be of the greatest | ||
703 | 626 | possible use to the public, the best way to achieve this is to make it | ||
704 | 627 | free software which everyone can redistribute and change under these terms. | ||
705 | 628 | |||
706 | 629 | To do so, attach the following notices to the program. It is safest | ||
707 | 630 | to attach them to the start of each source file to most effectively | ||
708 | 631 | state the exclusion of warranty; and each file should have at least | ||
709 | 632 | the "copyright" line and a pointer to where the full notice is found. | ||
710 | 633 | |||
711 | 634 | <one line to give the program's name and a brief idea of what it does.> | ||
712 | 635 | Copyright (C) <year> <name of author> | ||
713 | 636 | |||
714 | 637 | This program is free software: you can redistribute it and/or modify | ||
715 | 638 | it under the terms of the GNU General Public License as published by | ||
716 | 639 | the Free Software Foundation, either version 3 of the License, or | ||
717 | 640 | (at your option) any later version. | ||
718 | 641 | |||
719 | 642 | This program is distributed in the hope that it will be useful, | ||
720 | 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
721 | 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
722 | 645 | GNU General Public License for more details. | ||
723 | 646 | |||
724 | 647 | You should have received a copy of the GNU General Public License | ||
725 | 648 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
726 | 649 | |||
727 | 650 | Also add information on how to contact you by electronic and paper mail. | ||
728 | 651 | |||
729 | 652 | If the program does terminal interaction, make it output a short | ||
730 | 653 | notice like this when it starts in an interactive mode: | ||
731 | 654 | |||
732 | 655 | <program> Copyright (C) <year> <name of author> | ||
733 | 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
734 | 657 | This is free software, and you are welcome to redistribute it | ||
735 | 658 | under certain conditions; type `show c' for details. | ||
736 | 659 | |||
737 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
738 | 661 | parts of the General Public License. Of course, your program's commands | ||
739 | 662 | might be different; for a GUI interface, you would use an "about box". | ||
740 | 663 | |||
741 | 664 | You should also get your employer (if you work as a programmer) or school, | ||
742 | 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. | ||
743 | 666 | For more information on this, and how to apply and follow the GNU GPL, see | ||
744 | 667 | <http://www.gnu.org/licenses/>. | ||
745 | 668 | |||
746 | 669 | The GNU General Public License does not permit incorporating your program | ||
747 | 670 | into proprietary programs. If your program is a subroutine library, you | ||
748 | 671 | may consider it more useful to permit linking proprietary applications with | ||
749 | 672 | the library. If this is what you want to do, use the GNU Lesser General | ||
750 | 673 | Public License instead of this License. But first, please read | ||
751 | 674 | <http://www.gnu.org/philosophy/why-not-lgpl.html>. | ||
752 | 0 | 675 | ||
753 | === added file 'NOTICE.txt' | |||
754 | --- NOTICE.txt 1970-01-01 00:00:00 +0000 | |||
755 | +++ NOTICE.txt 2014-09-24 10:37:38 +0000 | |||
756 | @@ -0,0 +1,16 @@ | |||
757 | 1 | /* | ||
758 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
759 | 3 | * Copyright 2014 Canonical Ltd. | ||
760 | 4 | * | ||
761 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
762 | 6 | * under the terms of the GNU General Public License as published by | ||
763 | 7 | * the Free Software Foundation. | ||
764 | 8 | * | ||
765 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
766 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
767 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
768 | 12 | * See the GNU General Public License for more details. | ||
769 | 13 | * | ||
770 | 14 | * You should have received a copy of the GNU General Public License | ||
771 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
772 | 16 | */ | ||
773 | 0 | 17 | ||
774 | === added file 'README.org' | |||
775 | --- README.org 1970-01-01 00:00:00 +0000 | |||
776 | +++ README.org 2014-09-24 10:37:38 +0000 | |||
777 | @@ -0,0 +1,65 @@ | |||
778 | 1 | TimeOut scope prototype. | ||
779 | 2 | |||
780 | 3 | * Contact | ||
781 | 4 | |||
782 | 5 | Michał Karnicki <michal.karnicki@canonical.com> | ||
783 | 6 | |||
784 | 7 | * Running on desktop | ||
785 | 8 | |||
786 | 9 | $ ./build.sh | ||
787 | 10 | $ ./run.sh | ||
788 | 11 | |||
789 | 12 | * Building on the device | ||
790 | 13 | |||
791 | 14 | $ ./drop.sh | ||
792 | 15 | adb# su - phablet | ||
793 | 16 | adb$ cd $SCOPE_NAME | ||
794 | 17 | adb$ ./build.sh | ||
795 | 18 | adb$ ./click.sh | ||
796 | 19 | |||
797 | 20 | * Tools | ||
798 | 21 | |||
799 | 22 | A bunch of scripts that should make your life easier! | ||
800 | 23 | |||
801 | 24 | ** ./build.sh | ||
802 | 25 | Builds the scope locally. | ||
803 | 26 | |||
804 | 27 | If you want to clean then build, run: | ||
805 | 28 | $ ./build.sh . | ||
806 | 29 | |||
807 | 30 | If you are building for the first time, you'll need to install dependencies: | ||
808 | 31 | sudo ./deps.sh | ||
809 | 32 | If you're doing that on the phone, you'll first need to: | ||
810 | 33 | # note this will make your system not delta-upgradeable! | ||
811 | 34 | $ sudo mount -o rw,remount / | ||
812 | 35 | $ sudo apt-get update | ||
813 | 36 | $ sudo ./deps.sh | ||
814 | 37 | Note that mounting your file system writable will prevent from delta-upgrading your system. That means, you'll need to later flash your phone with up-to-date Ubuntu if you want to receive delta-updates. However, if you're a developer, no need to worry, you probably already use ubuntu-device-flash to often update your device manually. | ||
815 | 38 | |||
816 | 39 | ** ./run.sh | ||
817 | 40 | Runs the scope with unity-scope-tool. | ||
818 | 41 | $ sudo apt-get install unity-scope-tool | ||
819 | 42 | |||
820 | 43 | To set up run.sh, run this once: | ||
821 | 44 | $ sudo ./run.sh . | ||
822 | 45 | This requires sudo, because it tricks a click installation on your desktop. | ||
823 | 46 | In case you update renderer/* files, re-run this setup command. | ||
824 | 47 | |||
825 | 48 | ** ./drop.sh | ||
826 | 49 | Pushes current directory to the device, excluding .bzr, drops into adb shell. | ||
827 | 50 | |||
828 | 51 | ** ./click.sh | ||
829 | 52 | Creates and installs the click package on the device, after you have successfully ran build.sh. If on desktop, this will only attempt to build the click package (host architecture package). To workaround temporary issue, please run in adb shell: | ||
830 | 53 | $ sudo chmod o+w /opt/click.ubuntu.com/$SCOPE_PACKAGE/current/cache | ||
831 | 54 | sudo password is: phablet | ||
832 | 55 | |||
833 | 56 | ** ./clean.sh | ||
834 | 57 | Removes build and click directories and cmake configured files. | ||
835 | 58 | |||
836 | 59 | |||
837 | 60 | |||
838 | 61 | * Project tasks: | ||
839 | 62 | ** TODO i18n | ||
840 | 63 | ** TODO location (geoip, AGPS) | ||
841 | 64 | ** TODO make scope confined (mv apparmor/confined.json security.json) | ||
842 | 65 | ** TODO resolve the scope writable directory matter; update SCOPE_PATH in config.h.in | ||
843 | 0 | 66 | ||
844 | === added directory 'apparmor' | |||
845 | === added file 'apparmor/confined.json' | |||
846 | --- apparmor/confined.json 1970-01-01 00:00:00 +0000 | |||
847 | +++ apparmor/confined.json 2014-09-24 10:37:38 +0000 | |||
848 | @@ -0,0 +1,7 @@ | |||
849 | 1 | { | ||
850 | 2 | "template": "ubuntu-scope-network", | ||
851 | 3 | "policy_groups": [ | ||
852 | 4 | "networking" | ||
853 | 5 | ], | ||
854 | 6 | "policy_version": 1.2 | ||
855 | 7 | } | ||
856 | 0 | 8 | ||
857 | === added file 'apparmor/unconfined.json' | |||
858 | --- apparmor/unconfined.json 1970-01-01 00:00:00 +0000 | |||
859 | +++ apparmor/unconfined.json 2014-09-24 10:37:38 +0000 | |||
860 | @@ -0,0 +1,4 @@ | |||
861 | 1 | { | ||
862 | 2 | "template": "unconfined", | ||
863 | 3 | "policy_version": 1.2 | ||
864 | 4 | } | ||
865 | 0 | 5 | ||
866 | === added directory 'data' | |||
867 | === added file 'data/CMakeLists.txt' | |||
868 | --- data/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
869 | +++ data/CMakeLists.txt 2014-09-24 10:37:38 +0000 | |||
870 | @@ -0,0 +1,25 @@ | |||
871 | 1 | # Put the ini file in the build directory next to the scope | ||
872 | 2 | # .so file so test tools can find both easily. | ||
873 | 3 | configure_file( | ||
874 | 4 | timeout.ini.in | ||
875 | 5 | ${CMAKE_BINARY_DIR}/src/${SCOPE_PACKAGE}_${SCOPE_NAME}.ini) | ||
876 | 6 | |||
877 | 7 | INSTALL( | ||
878 | 8 | FILES ${CMAKE_BINARY_DIR}/src/${SCOPE_PACKAGE}_${SCOPE_NAME}.ini | ||
879 | 9 | DESTINATION ${INI_INSTALLDIR} | ||
880 | 10 | ) | ||
881 | 11 | |||
882 | 12 | INSTALL( | ||
883 | 13 | DIRECTORY "renderer" | ||
884 | 14 | DESTINATION "${INI_INSTALLDIR}" | ||
885 | 15 | ) | ||
886 | 16 | |||
887 | 17 | INSTALL( | ||
888 | 18 | FILES "icon.png" | ||
889 | 19 | DESTINATION "${INI_INSTALLDIR}" | ||
890 | 20 | ) | ||
891 | 21 | |||
892 | 22 | INSTALL( | ||
893 | 23 | FILES "./images/logo.png" | ||
894 | 24 | DESTINATION "${INI_INSTALLDIR}" | ||
895 | 25 | ) | ||
896 | 0 | 26 | ||
897 | === added file 'data/icon.png' | |||
898 | 1 | Binary files data/icon.png 1970-01-01 00:00:00 +0000 and data/icon.png 2014-09-24 10:37:38 +0000 differ | 27 | Binary files data/icon.png 1970-01-01 00:00:00 +0000 and data/icon.png 2014-09-24 10:37:38 +0000 differ |
899 | === added directory 'data/images' | |||
900 | === added file 'data/images/logo.png' | |||
901 | 2 | Binary files data/images/logo.png 1970-01-01 00:00:00 +0000 and data/images/logo.png 2014-09-24 10:37:38 +0000 differ | 28 | Binary files data/images/logo.png 1970-01-01 00:00:00 +0000 and data/images/logo.png 2014-09-24 10:37:38 +0000 differ |
902 | === added directory 'data/renderer' | |||
903 | === added file 'data/renderer/carousel.json' | |||
904 | --- data/renderer/carousel.json 1970-01-01 00:00:00 +0000 | |||
905 | +++ data/renderer/carousel.json 2014-09-24 10:37:38 +0000 | |||
906 | @@ -0,0 +1,12 @@ | |||
907 | 1 | { | ||
908 | 2 | "schema-version": 1, | ||
909 | 3 | "template": { | ||
910 | 4 | "category-layout": "carousel", | ||
911 | 5 | "card-size": "medium", | ||
912 | 6 | "overlay": true | ||
913 | 7 | }, | ||
914 | 8 | "components": { | ||
915 | 9 | "title": "title", | ||
916 | 10 | "art": "image" | ||
917 | 11 | } | ||
918 | 12 | } | ||
919 | 0 | 13 | ||
920 | === added file 'data/renderer/horizontal-list.json' | |||
921 | --- data/renderer/horizontal-list.json 1970-01-01 00:00:00 +0000 | |||
922 | +++ data/renderer/horizontal-list.json 2014-09-24 10:37:38 +0000 | |||
923 | @@ -0,0 +1,12 @@ | |||
924 | 1 | { | ||
925 | 2 | "schema-version": 1, | ||
926 | 3 | "template": { | ||
927 | 4 | "category-layout": "horizontal-list", | ||
928 | 5 | "card-size": "medium", | ||
929 | 6 | "overlay": true | ||
930 | 7 | }, | ||
931 | 8 | "components": { | ||
932 | 9 | "title": "title", | ||
933 | 10 | "art": "image" | ||
934 | 11 | } | ||
935 | 12 | } | ||
936 | 0 | 13 | ||
937 | === added file 'data/renderer/large-grid.json' | |||
938 | --- data/renderer/large-grid.json 1970-01-01 00:00:00 +0000 | |||
939 | +++ data/renderer/large-grid.json 2014-09-24 10:37:38 +0000 | |||
940 | @@ -0,0 +1,12 @@ | |||
941 | 1 | { | ||
942 | 2 | "schema-version": 1, | ||
943 | 3 | "template": { | ||
944 | 4 | "category-layout": "grid", | ||
945 | 5 | "card-size": "large", | ||
946 | 6 | "collapsed-rows": 1 | ||
947 | 7 | }, | ||
948 | 8 | "components": { | ||
949 | 9 | "art": "image-large", | ||
950 | 10 | "title": "title" | ||
951 | 11 | } | ||
952 | 12 | } | ||
953 | 0 | 13 | ||
954 | === added file 'data/renderer/medium-grid.json' | |||
955 | --- data/renderer/medium-grid.json 1970-01-01 00:00:00 +0000 | |||
956 | +++ data/renderer/medium-grid.json 2014-09-24 10:37:38 +0000 | |||
957 | @@ -0,0 +1,12 @@ | |||
958 | 1 | { | ||
959 | 2 | "schema-version": 1, | ||
960 | 3 | "template": { | ||
961 | 4 | "category-layout": "grid", | ||
962 | 5 | "card-size": "small", | ||
963 | 6 | "collapsed-rows": 1 | ||
964 | 7 | }, | ||
965 | 8 | "components": { | ||
966 | 9 | "art": { "field": "image", "aspect-ratio": 1 }, | ||
967 | 10 | "title": "title" | ||
968 | 11 | } | ||
969 | 12 | } | ||
970 | 0 | 13 | ||
971 | === added file 'data/renderer/vjournal.json' | |||
972 | --- data/renderer/vjournal.json 1970-01-01 00:00:00 +0000 | |||
973 | +++ data/renderer/vjournal.json 2014-09-24 10:37:38 +0000 | |||
974 | @@ -0,0 +1,15 @@ | |||
975 | 1 | { | ||
976 | 2 | "schema-version": 1, | ||
977 | 3 | "template": { | ||
978 | 4 | "category-layout": "vertical-journal", | ||
979 | 5 | "card-layout": "horizontal", | ||
980 | 6 | "card-size": "medium", | ||
981 | 7 | "collapsed-rows": 1 | ||
982 | 8 | }, | ||
983 | 9 | "components": { | ||
984 | 10 | "mascot": "image-small", | ||
985 | 11 | "title": "title", | ||
986 | 12 | "subtitle": "subtitle", | ||
987 | 13 | "summary": "summary" | ||
988 | 14 | } | ||
989 | 15 | } | ||
990 | 0 | 16 | ||
991 | === added file 'data/renderer/wide-art.json' | |||
992 | --- data/renderer/wide-art.json 1970-01-01 00:00:00 +0000 | |||
993 | +++ data/renderer/wide-art.json 2014-09-24 10:37:38 +0000 | |||
994 | @@ -0,0 +1,13 @@ | |||
995 | 1 | { | ||
996 | 2 | "schema-version": 1, | ||
997 | 3 | "template": { | ||
998 | 4 | "category-layout": "grid", | ||
999 | 5 | "card-size": "large", | ||
1000 | 6 | "overlay": true, | ||
1001 | 7 | "collapsed-rows": 0 | ||
1002 | 8 | }, | ||
1003 | 9 | "components": { | ||
1004 | 10 | "title": "title", | ||
1005 | 11 | "art": { "field": "image", "aspect-ratio": 2.5 } | ||
1006 | 12 | } | ||
1007 | 13 | } | ||
1008 | 0 | 14 | ||
1009 | === added file 'data/timeout.ini.in' | |||
1010 | --- data/timeout.ini.in 1970-01-01 00:00:00 +0000 | |||
1011 | +++ data/timeout.ini.in 2014-09-24 10:37:38 +0000 | |||
1012 | @@ -0,0 +1,13 @@ | |||
1013 | 1 | [ScopeConfig] | ||
1014 | 2 | DisplayName = TimeOut | ||
1015 | 3 | Description = This is an Ubuntu search plugin that enables information from TimeOut to be searched and displayed in the Dash. If you do not wish to search this content source, you can disable this search plugin. | ||
1016 | 4 | Icon = @SCOPE_ICON@ | ||
1017 | 5 | Author = Canonical Ltd. | ||
1018 | 6 | SearchHint = Search TimeOut | ||
1019 | 7 | LocationDataNeeded=true | ||
1020 | 8 | [Appearance] | ||
1021 | 9 | Background = @SCOPE_COLOR@ | ||
1022 | 10 | PageHeader.Logo = @SCOPE_LOGO@ | ||
1023 | 11 | PageHeader.Background = @BG_COLOR@ | ||
1024 | 12 | PageHeader.ForegroundColor = @FG_COLOR@ | ||
1025 | 13 | BackgroundColor = @SCOPE_BG_COLOR@ | ||
1026 | 0 | 14 | ||
1027 | === added file 'manifest.json.in' | |||
1028 | --- manifest.json.in 1970-01-01 00:00:00 +0000 | |||
1029 | +++ manifest.json.in 2014-09-24 10:37:38 +0000 | |||
1030 | @@ -0,0 +1,15 @@ | |||
1031 | 1 | { | ||
1032 | 2 | "name": "@SCOPE_PACKAGE@", | ||
1033 | 3 | "description": "@SCOPE_DESC@", | ||
1034 | 4 | "framework": "@FRAMEWORK@", | ||
1035 | 5 | "architecture": "@ARCH@", | ||
1036 | 6 | "title": "@SCOPE_TITLE@", | ||
1037 | 7 | "hooks": { | ||
1038 | 8 | "@SCOPE_NAME@": { | ||
1039 | 9 | "scope": "@SCOPE_NAME@", | ||
1040 | 10 | "apparmor": "security.json" | ||
1041 | 11 | } | ||
1042 | 12 | }, | ||
1043 | 13 | "version": "0.4.9", | ||
1044 | 14 | "maintainer": "@SCOPE_MAINTAINER@" | ||
1045 | 15 | } | ||
1046 | 0 | 16 | ||
1047 | === added file 'push.sh' | |||
1048 | --- push.sh 1970-01-01 00:00:00 +0000 | |||
1049 | +++ push.sh 2014-09-24 10:37:38 +0000 | |||
1050 | @@ -0,0 +1,8 @@ | |||
1051 | 1 | #!/bin/bash | ||
1052 | 2 | |||
1053 | 3 | for click in `ls *.click`;do | ||
1054 | 4 | adb push $click /home/phablet | ||
1055 | 5 | done | ||
1056 | 6 | |||
1057 | 7 | adb shell "find /home/phablet/ -name *.click -exec pkcon --allow-untrusted install-local {} \;" | ||
1058 | 8 | adb shell "rm /home/phablet/*.click" | ||
1059 | 0 | 9 | ||
1060 | === added file 'run.sh' | |||
1061 | --- run.sh 1970-01-01 00:00:00 +0000 | |||
1062 | +++ run.sh 2014-09-24 10:37:38 +0000 | |||
1063 | @@ -0,0 +1,24 @@ | |||
1064 | 1 | #!/bin/bash | ||
1065 | 2 | |||
1066 | 3 | if [ $# -eq 1 ]; then | ||
1067 | 4 | OWNER=$SUDO_USER | ||
1068 | 5 | if [ "$OWNER" = "" ]; then | ||
1069 | 6 | OWNER=$USER | ||
1070 | 7 | fi | ||
1071 | 8 | PACKAGE=`head CMakeLists.txt |grep SCOPE_PACKAGE|cut -d" " -f 2|tr -d "\")"` | ||
1072 | 9 | DEST="/opt/click.ubuntu.com/$PACKAGE/current" | ||
1073 | 10 | |||
1074 | 11 | sudo mkdir -p $DEST | ||
1075 | 12 | # sudo cp -r data/departments.json $DEST/ | ||
1076 | 13 | sudo cp -r data/renderer $DEST/ | ||
1077 | 14 | # sudo cp -r data/images $DEST/ | ||
1078 | 15 | sudo cp -r data/cache $DEST/ | ||
1079 | 16 | |||
1080 | 17 | sudo chown $OWNER:$OWNER $DEST/cache | ||
1081 | 18 | echo "Setup complete." | ||
1082 | 19 | exit 0; | ||
1083 | 20 | fi | ||
1084 | 21 | |||
1085 | 22 | cd build/src | ||
1086 | 23 | path=`pwd` | ||
1087 | 24 | unity-scope-tool $path/*.ini | ||
1088 | 0 | 25 | ||
1089 | === added file 'security.json' | |||
1090 | --- security.json 1970-01-01 00:00:00 +0000 | |||
1091 | +++ security.json 2014-09-24 10:37:38 +0000 | |||
1092 | @@ -0,0 +1,5 @@ | |||
1093 | 1 | { | ||
1094 | 2 | "template": "ubuntu-scope-network", | ||
1095 | 3 | "policy_groups": [], | ||
1096 | 4 | "policy_version": 1.2 | ||
1097 | 5 | } | ||
1098 | 0 | 6 | ||
1099 | === added directory 'src' | |||
1100 | === renamed directory 'src' => 'src.moved' | |||
1101 | === added file 'src/CMakeLists.txt' | |||
1102 | --- src/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1103 | +++ src/CMakeLists.txt 2014-09-24 10:37:38 +0000 | |||
1104 | @@ -0,0 +1,22 @@ | |||
1105 | 1 | add_definitions(-DQT_NO_KEYWORDS) | ||
1106 | 2 | |||
1107 | 3 | find_package(Qt5Network REQUIRED) | ||
1108 | 4 | set(CMAKE_AUTOMOC ON) | ||
1109 | 5 | |||
1110 | 6 | add_library(${SCOPE_PACKAGE}_${SCOPE_NAME} SHARED TimeOut-preview.cpp TimeOut-query.cpp TimeOut-scope.cpp TimeOut-client.cpp) | ||
1111 | 7 | |||
1112 | 8 | target_link_libraries(${SCOPE_PACKAGE}_${SCOPE_NAME} ${UNITY_SCOPES_LDFLAGS}) | ||
1113 | 9 | set_property(TARGET ${SCOPE_PACKAGE}_${SCOPE_NAME} PROPERTY COMPILE_FLAGS ${UNITY_SCOPES_CFLAGS}) | ||
1114 | 10 | |||
1115 | 11 | qt5_use_modules(${SCOPE_PACKAGE}_${SCOPE_NAME} Network) | ||
1116 | 12 | qt5_use_modules(${SCOPE_PACKAGE}_${SCOPE_NAME} Gui) | ||
1117 | 13 | |||
1118 | 14 | CONFIGURE_FILE( | ||
1119 | 15 | "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" | ||
1120 | 16 | "${CMAKE_CURRENT_SOURCE_DIR}/config.h" | ||
1121 | 17 | ) | ||
1122 | 18 | |||
1123 | 19 | install( | ||
1124 | 20 | TARGETS ${SCOPE_PACKAGE}_${SCOPE_NAME} | ||
1125 | 21 | LIBRARY DESTINATION ${SCOPE_INSTALLDIR} | ||
1126 | 22 | ) | ||
1127 | 0 | 23 | ||
1128 | === added file 'src/TimeOut-client.cpp' | |||
1129 | --- src/TimeOut-client.cpp 1970-01-01 00:00:00 +0000 | |||
1130 | +++ src/TimeOut-client.cpp 2014-09-24 10:37:38 +0000 | |||
1131 | @@ -0,0 +1,372 @@ | |||
1132 | 1 | /* | ||
1133 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
1134 | 3 | * Copyright 2014 Canonical Ltd. | ||
1135 | 4 | * | ||
1136 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
1137 | 6 | * under the terms of the GNU General Public License as published by | ||
1138 | 7 | * the Free Software Foundation. | ||
1139 | 8 | * | ||
1140 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
1141 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1142 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
1143 | 12 | * See the GNU General Public License for more details. | ||
1144 | 13 | * | ||
1145 | 14 | * You should have received a copy of the GNU General Public License | ||
1146 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
1147 | 16 | */ | ||
1148 | 17 | |||
1149 | 18 | #include "TimeOut-client.h" | ||
1150 | 19 | |||
1151 | 20 | #include <chrono> | ||
1152 | 21 | #include <utility> | ||
1153 | 22 | |||
1154 | 23 | #include <QCoreApplication> | ||
1155 | 24 | #include <QNetworkDiskCache> | ||
1156 | 25 | |||
1157 | 26 | #define VERBOSE | ||
1158 | 27 | |||
1159 | 28 | #define TIMING | ||
1160 | 29 | |||
1161 | 30 | #ifdef TIMING | ||
1162 | 31 | #define INIT_TIMER auto start = std::chrono::high_resolution_clock::now(); | ||
1163 | 32 | #define START_TIMER start = std::chrono::high_resolution_clock::now(); | ||
1164 | 33 | #define STOP_TIMER(name) qDebug() << "RUNTIME of " << name << ": " << \ | ||
1165 | 34 | std::chrono::duration_cast<std::chrono::milliseconds>( \ | ||
1166 | 35 | std::chrono::high_resolution_clock::now()-start \ | ||
1167 | 36 | ).count() << " ms "; | ||
1168 | 37 | #else | ||
1169 | 38 | #define INIT_TIMER | ||
1170 | 39 | #define START_TIMER | ||
1171 | 40 | #define STOP_TIMER(name) | ||
1172 | 41 | #endif | ||
1173 | 42 | |||
1174 | 43 | #define FOREACH_JSON(it, results) for (QJsonArray::iterator it = results.begin(); it != results.end(); ++it) | ||
1175 | 44 | |||
1176 | 45 | const QString USER_AGENT = "TimeOut Scope (Ubuntu)"; | ||
1177 | 46 | const QString GEO_LOOKUP = "http://geoip.ubuntu.com/lookup"; | ||
1178 | 47 | const QString URL = "http://graffiti.timeout.com/v1"; | ||
1179 | 48 | const QString KEY = "key-goes-here"; | ||
1180 | 49 | |||
1181 | 50 | const QString AUTH_HEADER = "Bearer %1"; | ||
1182 | 51 | |||
1183 | 52 | using namespace Qt; | ||
1184 | 53 | |||
1185 | 54 | TimeOut::TimeOut() { | ||
1186 | 55 | useAltCity = false; | ||
1187 | 56 | } | ||
1188 | 57 | |||
1189 | 58 | void print(QMap<QString, QString> map) { | ||
1190 | 59 | QMap<QString, QString>::iterator it; | ||
1191 | 60 | for (it = map.begin(); it != map.end(); ++it) | ||
1192 | 61 | qDebug() << it.key() << ": " << it.value(); | ||
1193 | 62 | } | ||
1194 | 63 | QMap<QString,QString> TimeOut::getCityLogos() { | ||
1195 | 64 | QMap<QString,QString> myMap; | ||
1196 | 65 | myMap["Accra"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/accra.png"; | ||
1197 | 66 | myMap["Amsterdam"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/amsterdam.png"; | ||
1198 | 67 | myMap["Barcelona"]="http://www.timeout.cat/bundles/timeoutfrontend/images/logos/bcn.png"; | ||
1199 | 68 | myMap["Berlin"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/berlin.png"; | ||
1200 | 69 | myMap["Boston"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/boston.png"; | ||
1201 | 70 | myMap["Chicago"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/chicago.png"; | ||
1202 | 71 | myMap["Kuala Lumpur"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/kualalumpur.png"; | ||
1203 | 72 | myMap["Las Vegas"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/lasvegas.png"; | ||
1204 | 73 | myMap["London"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/london.png"; | ||
1205 | 74 | myMap["Los Angeles"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/la.png"; | ||
1206 | 75 | myMap["Madrid"]="http://www.timeout.es/bundles/timeoutfrontend/images/logos/madrid.png"; | ||
1207 | 76 | myMap["Miami"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/miami.png"; | ||
1208 | 77 | myMap["México, DF"]="http://www.timeoutmexico.mx/bundles/timeoutfrontend/images/logos/mex.png"; | ||
1209 | 78 | myMap["New York"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/ny.png"; | ||
1210 | 79 | myMap["Paris"]="http://www.timeout.fr/bundles/timeoutfrontend/images/logos/paris.png"; | ||
1211 | 80 | myMap["Washington, DC"]="http://www.timeout.com/bundles/timeoutfrontend/images/logos/washingtondc.png"; | ||
1212 | 81 | myMap["unknown"]="http://www.timeout.com/wp-content/uploads/2014/06/TO-web-logo-global.png"; | ||
1213 | 82 | return myMap; | ||
1214 | 83 | } | ||
1215 | 84 | |||
1216 | 85 | void TimeOut::setCacheDirectory(std::string const &cacheDirectory) { | ||
1217 | 86 | scopeCache = QString::fromStdString(cacheDirectory); | ||
1218 | 87 | } | ||
1219 | 88 | |||
1220 | 89 | bool inBox(locBox box, coordinates point){ | ||
1221 | 90 | double big,small; | ||
1222 | 91 | if(box.bottom > box.top){ | ||
1223 | 92 | big=box.bottom; | ||
1224 | 93 | small=box.top; | ||
1225 | 94 | } else { | ||
1226 | 95 | big=box.top; | ||
1227 | 96 | small=box.bottom; | ||
1228 | 97 | } | ||
1229 | 98 | if (!(point.lat<big && point.lat > small)) | ||
1230 | 99 | return false; | ||
1231 | 100 | |||
1232 | 101 | if(box.left > box.right){ | ||
1233 | 102 | big=box.left; | ||
1234 | 103 | small=box.right; | ||
1235 | 104 | } else { | ||
1236 | 105 | big=box.right; | ||
1237 | 106 | small=box.left; | ||
1238 | 107 | } | ||
1239 | 108 | if (!(point.lon<big && point.lon > small)) | ||
1240 | 109 | return false; | ||
1241 | 110 | |||
1242 | 111 | return true; | ||
1243 | 112 | |||
1244 | 113 | } | ||
1245 | 114 | |||
1246 | 115 | bool TimeOut::setupCity() { | ||
1247 | 116 | coordinates city = getCurrentCity(); | ||
1248 | 117 | std::vector<CityType> cities = fetchSupportedCities(); | ||
1249 | 118 | for (unsigned int i = 0 ; i < cities.size(); i++){ | ||
1250 | 119 | if (inBox(cities[i].box,city)) { | ||
1251 | 120 | this->city = cities[i].name; | ||
1252 | 121 | this->url = QUrl(cities[i].url); | ||
1253 | 122 | qDebug() << "City set to: " << this->city; | ||
1254 | 123 | useCurrentCity(); | ||
1255 | 124 | return true; | ||
1256 | 125 | } | ||
1257 | 126 | } | ||
1258 | 127 | qDebug() << "Unsupported location " << city.lat <<" : " <<city.lon; | ||
1259 | 128 | this->city = ""; | ||
1260 | 129 | this->url = ""; | ||
1261 | 130 | return false; | ||
1262 | 131 | } | ||
1263 | 132 | |||
1264 | 133 | QString TimeOut::getCityFromUrl(QString url) { | ||
1265 | 134 | |||
1266 | 135 | auto iCity = url.right(url.size() - url.indexOf("mobile") - 7); | ||
1267 | 136 | iCity = iCity.left(iCity.indexOf("/")); | ||
1268 | 137 | qDebug() << "city from url is " <<iCity << " for " << url; | ||
1269 | 138 | auto cities = getSupportedCities(); | ||
1270 | 139 | for (unsigned int i = 0 ; i < cities.size(); i++){ | ||
1271 | 140 | if(cities[i].url.contains(iCity)) | ||
1272 | 141 | return cities[i].url; | ||
1273 | 142 | } | ||
1274 | 143 | return ""; | ||
1275 | 144 | } | ||
1276 | 145 | |||
1277 | 146 | QByteArray TimeOut::makeRequest(QNetworkRequest &request) const { | ||
1278 | 147 | int argc = 1; | ||
1279 | 148 | char *argv = const_cast<char*>("timeout-scope"); | ||
1280 | 149 | QCoreApplication *app = new QCoreApplication(argc, &argv); | ||
1281 | 150 | QNetworkAccessManager manager; | ||
1282 | 151 | QByteArray reply; | ||
1283 | 152 | QNetworkDiskCache *cache = new QNetworkDiskCache(); | ||
1284 | 153 | cache->setCacheDirectory(scopeCache); | ||
1285 | 154 | |||
1286 | 155 | QString authorizationHeader = AUTH_HEADER.arg(KEY); | ||
1287 | 156 | request.setRawHeader("Authorization", authorizationHeader.toStdString().c_str()); | ||
1288 | 157 | request.setRawHeader("User-Agent", USER_AGENT.toStdString().c_str()); | ||
1289 | 158 | request.setRawHeader("Content-Type", "application/json"); | ||
1290 | 159 | request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); | ||
1291 | 160 | |||
1292 | 161 | QObject::connect(&manager, SIGNAL(finished(QNetworkReply*)), app, SLOT(quit())); | ||
1293 | 162 | QObject::connect(&manager, &QNetworkAccessManager::finished, | ||
1294 | 163 | [&reply](QNetworkReply *msg) { | ||
1295 | 164 | reply = msg->readAll(); | ||
1296 | 165 | msg->deleteLater(); | ||
1297 | 166 | }); | ||
1298 | 167 | |||
1299 | 168 | manager.setCache(cache); | ||
1300 | 169 | manager.get(request); | ||
1301 | 170 | app->exec(); | ||
1302 | 171 | |||
1303 | 172 | delete cache; | ||
1304 | 173 | return reply; | ||
1305 | 174 | } | ||
1306 | 175 | |||
1307 | 176 | QJsonValuePair TimeOut::get(QUrl url, int = 1) const { | ||
1308 | 177 | INIT_TIMER | ||
1309 | 178 | START_TIMER | ||
1310 | 179 | QNetworkRequest request(url); // Add paging when we support it. | ||
1311 | 180 | QByteArray data = makeRequest(request); | ||
1312 | 181 | STOP_TIMER(QString("GET ").append(url.path())); | ||
1313 | 182 | |||
1314 | 183 | QJsonParseError e; | ||
1315 | 184 | QJsonDocument document = QJsonDocument::fromJson(data, &e); | ||
1316 | 185 | if (e.error != QJsonParseError::NoError) { | ||
1317 | 186 | qCritical() << "failed to parse response " << e.errorString() << "\n" << QString(data); | ||
1318 | 187 | throw QString("Failed to parse response: %1").arg(e.errorString()); | ||
1319 | 188 | } | ||
1320 | 189 | |||
1321 | 190 | if(!document.isObject()) { | ||
1322 | 191 | throw QString("json is not an object"); | ||
1323 | 192 | } | ||
1324 | 193 | QJsonObject object = document.object(); | ||
1325 | 194 | if (object.contains("meta")) { | ||
1326 | 195 | QJsonValue meta = object.value("meta"); | ||
1327 | 196 | QJsonValue body = object.value("body"); | ||
1328 | 197 | |||
1329 | 198 | return RESPONSE(meta, body); | ||
1330 | 199 | } else { | ||
1331 | 200 | // XXX workaround for inconsistent "curateds" API endpoint format | ||
1332 | 201 | qCritical() << "No 'meta' tag present!"; | ||
1333 | 202 | QJsonValue meta, body; | ||
1334 | 203 | if (document.isArray()) { | ||
1335 | 204 | body = document.array(); | ||
1336 | 205 | } | ||
1337 | 206 | return RESPONSE(meta, body); | ||
1338 | 207 | } | ||
1339 | 208 | } | ||
1340 | 209 | |||
1341 | 210 | coordinates TimeOut::getCurrentCity() { | ||
1342 | 211 | //Insert coordinates here for test | ||
1343 | 212 | //mycoordinates.lat= 41.4583; mycoordinates.lon= 2.0625; //Barcelona | ||
1344 | 213 | //mycoordinates.lat= 41.1583; mycoordinates.lon= -3.6625; //Madrid | ||
1345 | 214 | //mycoordinates.lat= 0; mycoordinates.lon= 0; //nowhere | ||
1346 | 215 | |||
1347 | 216 | |||
1348 | 217 | qDebug()<< "lat is " << mycoordinates.lat << " , long is " <<mycoordinates.lon; | ||
1349 | 218 | |||
1350 | 219 | return mycoordinates; | ||
1351 | 220 | } | ||
1352 | 221 | |||
1353 | 222 | std::vector<CityType> TimeOut::fetchSupportedCities() { | ||
1354 | 223 | QUrl url(URL + "/mobile"); | ||
1355 | 224 | auto response = get(url); | ||
1356 | 225 | supportedCities.clear(); | ||
1357 | 226 | |||
1358 | 227 | qDebug() <<"my locale is" << locale_; | ||
1359 | 228 | QJsonValue body = response.second; | ||
1360 | 229 | QJsonArray results = body.toArray(); | ||
1361 | 230 | QJsonArray::iterator it; | ||
1362 | 231 | for (it = results.begin(); it != results.end(); ++it) { | ||
1363 | 232 | CityType iCity; | ||
1364 | 233 | QJsonObject o = (*it).toObject(); | ||
1365 | 234 | |||
1366 | 235 | //get coordinates for the city | ||
1367 | 236 | QJsonObject boundingBox = o.value("bounding_box").toObject(); | ||
1368 | 237 | iCity.box.top=boundingBox.value("top").toDouble(); | ||
1369 | 238 | iCity.box.bottom=boundingBox.value("bottom").toDouble(); | ||
1370 | 239 | iCity.box.right=boundingBox.value("right").toDouble(); | ||
1371 | 240 | iCity.box.left=boundingBox.value("left").toDouble(); | ||
1372 | 241 | QJsonObject defaultLocale = o.value("default_locale").toObject(); | ||
1373 | 242 | iCity.name = defaultLocale.value("name").toString(); | ||
1374 | 243 | //blacklist accra as seems broken | ||
1375 | 244 | if (iCity.name == "Accra") | ||
1376 | 245 | continue; | ||
1377 | 246 | iCity.url = defaultLocale.value("url").toString(); | ||
1378 | 247 | QJsonArray locales = o.value("locales").toArray(); | ||
1379 | 248 | |||
1380 | 249 | bool locale_found=false; | ||
1381 | 250 | bool en_found=false; | ||
1382 | 251 | QString en_url=""; | ||
1383 | 252 | |||
1384 | 253 | //check if my locale is supported | ||
1385 | 254 | FOREACH_JSON(alocal,locales) { | ||
1386 | 255 | QJsonObject o = (*alocal).toObject(); | ||
1387 | 256 | auto loc_lang = o.value("id").toString(); | ||
1388 | 257 | qDebug()<<"city supports:" <<loc_lang << "checking against" <<locale_; | ||
1389 | 258 | if (loc_lang.contains(locale_)) { | ||
1390 | 259 | iCity.url = o.value("url").toString(); | ||
1391 | 260 | locale_found =true; | ||
1392 | 261 | } | ||
1393 | 262 | if (loc_lang.contains("en")) { | ||
1394 | 263 | en_url = o.value("url").toString(); | ||
1395 | 264 | en_found =true; | ||
1396 | 265 | } | ||
1397 | 266 | } | ||
1398 | 267 | //if my locale is not found, then try english, if not default | ||
1399 | 268 | if (!locale_found && en_found) iCity.url = en_url; | ||
1400 | 269 | |||
1401 | 270 | #ifdef VERBOSE | ||
1402 | 271 | qDebug() << iCity.name << " url :" << iCity.url << "\nbox :\nbottom " << iCity.box.bottom | ||
1403 | 272 | <<"left "<< iCity.box.left | ||
1404 | 273 | << "top "<< iCity.box.top | ||
1405 | 274 | << "right " <<iCity.box.right; | ||
1406 | 275 | #endif | ||
1407 | 276 | supportedCities.push_back(iCity); | ||
1408 | 277 | } | ||
1409 | 278 | return supportedCities; | ||
1410 | 279 | } | ||
1411 | 280 | |||
1412 | 281 | void TimeOut::getCityEndpoints() { | ||
1413 | 282 | site.clear(); | ||
1414 | 283 | auto response = get(useAltCity?this->alternateUrl:this->url, 1); | ||
1415 | 284 | |||
1416 | 285 | QJsonValue body = response.second; | ||
1417 | 286 | QJsonArray results = body.toArray(); | ||
1418 | 287 | QJsonArray::iterator it; | ||
1419 | 288 | for (it = results.begin(); it != results.end(); ++it) { | ||
1420 | 289 | QJsonObject endpoint = (*it).toObject(); | ||
1421 | 290 | QString id = endpoint.value("id").toString(); | ||
1422 | 291 | QString url = endpoint.value("url").toString(); | ||
1423 | 292 | #ifdef VERBOSE | ||
1424 | 293 | qDebug() << id; | ||
1425 | 294 | #endif | ||
1426 | 295 | site[id] = QUrl(url); | ||
1427 | 296 | } | ||
1428 | 297 | } | ||
1429 | 298 | |||
1430 | 299 | QJsonValuePair TimeOut::getEndpoint(QString endpoint, int page) const { | ||
1431 | 300 | /* | ||
1432 | 301 | "booking-providers" | ||
1433 | 302 | "canned-queries" | ||
1434 | 303 | "curateds" | ||
1435 | 304 | "editor-lists" | ||
1436 | 305 | "editor-picks" | ||
1437 | 306 | "facet-groups" | ||
1438 | 307 | "page-types" | ||
1439 | 308 | "pages" | ||
1440 | 309 | "search" | ||
1441 | 310 | "windows" | ||
1442 | 311 | */ | ||
1443 | 312 | return this->get(this->site[endpoint], page); | ||
1444 | 313 | } | ||
1445 | 314 | |||
1446 | 315 | QJsonArray TimeOut::getCannedQueries(int page = 1) const { | ||
1447 | 316 | QJsonValuePair response = getEndpoint(QString("canned-queries"), page); | ||
1448 | 317 | return BODY(response); | ||
1449 | 318 | } | ||
1450 | 319 | |||
1451 | 320 | QJsonArray TimeOut::getCurated(int page = 1) const { | ||
1452 | 321 | auto response = getEndpoint(QString("curateds"), page); | ||
1453 | 322 | return BODY(response); | ||
1454 | 323 | } | ||
1455 | 324 | |||
1456 | 325 | QJsonArray TimeOut::getEditorLists(int page = 1) const { | ||
1457 | 326 | auto response = getEndpoint(QString("editor-lists"), page); | ||
1458 | 327 | return BODY(response); | ||
1459 | 328 | } | ||
1460 | 329 | |||
1461 | 330 | QJsonArray TimeOut::getEditorPicks(int page = 1) const { | ||
1462 | 331 | auto response = getEndpoint(QString("editor-picks"), page); | ||
1463 | 332 | return BODY(response); | ||
1464 | 333 | } | ||
1465 | 334 | |||
1466 | 335 | QJsonArray TimeOut::getFacetGroups(int page = 1) const { | ||
1467 | 336 | auto response = getEndpoint(QString("facet-groups"), page); | ||
1468 | 337 | return BODY(response); | ||
1469 | 338 | } | ||
1470 | 339 | |||
1471 | 340 | QJsonArray TimeOut::search(QString query, int page = 1) const { | ||
1472 | 341 | QString lat= QString::number(mycoordinates.lat); | ||
1473 | 342 | QString lng= QString::number(mycoordinates.lon);; | ||
1474 | 343 | QString radius("2"); | ||
1475 | 344 | |||
1476 | 345 | QString location = QString("&latitude=%1&longitude=%2&radius=%3") | ||
1477 | 346 | .arg(lat).arg(lng).arg(radius); | ||
1478 | 347 | QString s = this->site["search"].toString() + QString("&q=%1").arg(query) + location; | ||
1479 | 348 | auto response = this->get(QUrl(s), page); | ||
1480 | 349 | return BODY(response); | ||
1481 | 350 | } | ||
1482 | 351 | /* | ||
1483 | 352 | // This is left here for standalone test runs. | ||
1484 | 353 | int main(int argc, char **argv) { | ||
1485 | 354 | TimeOut timeout; | ||
1486 | 355 | timeout.setupCity(); | ||
1487 | 356 | |||
1488 | 357 | QJsonArray curated = timeout.getCurated(); | ||
1489 | 358 | if (curated.empty()) { | ||
1490 | 359 | qWarning() << "no curated results!"; | ||
1491 | 360 | } | ||
1492 | 361 | #ifdef VERBOSE | ||
1493 | 362 | QJsonArray::iterator it; | ||
1494 | 363 | for (it = curated.begin(); it != curated.end(); ++it) { | ||
1495 | 364 | QJsonObject item = (*it).toObject(); | ||
1496 | 365 | QString name = item.value("name").toString(); | ||
1497 | 366 | QString url = item.value("url").toString(); | ||
1498 | 367 | qDebug() << name << ": " << url; | ||
1499 | 368 | } | ||
1500 | 369 | #endif | ||
1501 | 370 | return 0; | ||
1502 | 371 | } | ||
1503 | 372 | */ | ||
1504 | 0 | 373 | ||
1505 | === added file 'src/TimeOut-client.h' | |||
1506 | --- src/TimeOut-client.h 1970-01-01 00:00:00 +0000 | |||
1507 | +++ src/TimeOut-client.h 2014-09-24 10:37:38 +0000 | |||
1508 | @@ -0,0 +1,101 @@ | |||
1509 | 1 | /* | ||
1510 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
1511 | 3 | * Copyright 2014 Canonical Ltd. | ||
1512 | 4 | * | ||
1513 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
1514 | 6 | * under the terms of the GNU General Public License as published by | ||
1515 | 7 | * the Free Software Foundation. | ||
1516 | 8 | * | ||
1517 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
1518 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1519 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
1520 | 12 | * See the GNU General Public License for more details. | ||
1521 | 13 | * | ||
1522 | 14 | * You should have received a copy of the GNU General Public License | ||
1523 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
1524 | 16 | */ | ||
1525 | 17 | |||
1526 | 18 | #ifndef TIMEOUT_CLIENT_H | ||
1527 | 19 | #define TIMEOUT_CLIENT_H | ||
1528 | 20 | |||
1529 | 21 | #include "config.h" | ||
1530 | 22 | |||
1531 | 23 | #include <QNetworkAccessManager> | ||
1532 | 24 | #include <QNetworkReply> | ||
1533 | 25 | #include <QNetworkRequest> | ||
1534 | 26 | |||
1535 | 27 | #include <QJsonArray> | ||
1536 | 28 | #include <QJsonDocument> | ||
1537 | 29 | #include <QJsonObject> | ||
1538 | 30 | |||
1539 | 31 | #define RESPONSE(meta, body) std::make_pair(meta, body) | ||
1540 | 32 | #define META(response) response.first | ||
1541 | 33 | #define BODY(response) response.second.toArray() | ||
1542 | 34 | #define COORDINATES(cor,lon, lat) cor.lon=lon;\cor.lat=lat | ||
1543 | 35 | |||
1544 | 36 | typedef std::pair<QJsonValue, QJsonValue> QJsonValuePair; | ||
1545 | 37 | |||
1546 | 38 | //city location | ||
1547 | 39 | struct coordinates { | ||
1548 | 40 | double lon; | ||
1549 | 41 | double lat; | ||
1550 | 42 | }; | ||
1551 | 43 | |||
1552 | 44 | struct locBox { | ||
1553 | 45 | double top; | ||
1554 | 46 | double bottom; | ||
1555 | 47 | double left; | ||
1556 | 48 | double right; | ||
1557 | 49 | }; | ||
1558 | 50 | struct CityType { | ||
1559 | 51 | QString name; | ||
1560 | 52 | QString url; | ||
1561 | 53 | locBox box; | ||
1562 | 54 | }; | ||
1563 | 55 | |||
1564 | 56 | class TimeOut | ||
1565 | 57 | { | ||
1566 | 58 | |||
1567 | 59 | public: | ||
1568 | 60 | TimeOut(); | ||
1569 | 61 | QJsonValuePair get(QUrl, int) const; | ||
1570 | 62 | |||
1571 | 63 | void setCacheDirectory(std::string const&); | ||
1572 | 64 | bool setupCity(); | ||
1573 | 65 | void setLocale(QString const& locale) { locale_ = locale; } | ||
1574 | 66 | void setLocation(double lat, double lon) { mycoordinates.lat=lat;mycoordinates.lon =lon; } | ||
1575 | 67 | coordinates getCurrentCity(); | ||
1576 | 68 | QString getCityName() {return city;} | ||
1577 | 69 | QString getCityUrl(){ return url.toString();} | ||
1578 | 70 | QString getCityFromUrl(QString url); | ||
1579 | 71 | std::vector<CityType> fetchSupportedCities(); | ||
1580 | 72 | std::vector<CityType> getSupportedCities() {return supportedCities;} | ||
1581 | 73 | QMap<QString,QString> getCityLogos(); | ||
1582 | 74 | void getCityEndpoints(); | ||
1583 | 75 | QJsonValuePair getEndpoint(QString, int) const; | ||
1584 | 76 | QJsonArray getCannedQueries(int) const; | ||
1585 | 77 | QJsonArray getCurated(int) const; | ||
1586 | 78 | QJsonArray getEditorLists(int) const; | ||
1587 | 79 | QJsonArray getEditorPicks(int) const; | ||
1588 | 80 | QJsonArray getFacetGroups(int) const; | ||
1589 | 81 | QJsonArray search(QString query, int) const; | ||
1590 | 82 | void useAlternateCity(const QString& url) { useAltCity =true; alternateUrl =QUrl(url); getCityEndpoints();} | ||
1591 | 83 | void useCurrentCity() {useAltCity=false;getCityEndpoints();} | ||
1592 | 84 | protected: | ||
1593 | 85 | QByteArray makeRequest(QNetworkRequest &) const; | ||
1594 | 86 | |||
1595 | 87 | private: | ||
1596 | 88 | QString scopeCache; | ||
1597 | 89 | QString city; | ||
1598 | 90 | QUrl url; | ||
1599 | 91 | QUrl alternateUrl; | ||
1600 | 92 | bool useAltCity; | ||
1601 | 93 | QMap<QString, QUrl> site; | ||
1602 | 94 | coordinates mycoordinates; | ||
1603 | 95 | QString locale_; | ||
1604 | 96 | std::vector<CityType> supportedCities; | ||
1605 | 97 | |||
1606 | 98 | |||
1607 | 99 | }; | ||
1608 | 100 | |||
1609 | 101 | #endif | ||
1610 | 0 | 102 | ||
1611 | === added file 'src/TimeOut-preview.cpp' | |||
1612 | --- src/TimeOut-preview.cpp 1970-01-01 00:00:00 +0000 | |||
1613 | +++ src/TimeOut-preview.cpp 2014-09-24 10:37:38 +0000 | |||
1614 | @@ -0,0 +1,413 @@ | |||
1615 | 1 | /* | ||
1616 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
1617 | 3 | * Copyright 2014 Canonical Ltd. | ||
1618 | 4 | * | ||
1619 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
1620 | 6 | * under the terms of the GNU General Public License as published by | ||
1621 | 7 | * the Free Software Foundation. | ||
1622 | 8 | * | ||
1623 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
1624 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1625 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
1626 | 12 | * See the GNU General Public License for more details. | ||
1627 | 13 | * | ||
1628 | 14 | * You should have received a copy of the GNU General Public License | ||
1629 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
1630 | 16 | */ | ||
1631 | 17 | |||
1632 | 18 | #include "TimeOut-preview.h" | ||
1633 | 19 | |||
1634 | 20 | #include <unity/scopes/PreviewWidget.h> | ||
1635 | 21 | #include <unity/scopes/ColumnLayout.h> | ||
1636 | 22 | #include <unity/scopes/PreviewReply.h> | ||
1637 | 23 | #include <unity/scopes/VariantBuilder.h> | ||
1638 | 24 | |||
1639 | 25 | #include <QDebug> | ||
1640 | 26 | #include <QString> | ||
1641 | 27 | |||
1642 | 28 | using namespace unity::scopes; | ||
1643 | 29 | |||
1644 | 30 | TimeoutPreview::TimeoutPreview(Result const& result, ActionMetadata const& metadata, TimeOut const& timeout) | ||
1645 | 31 | : PreviewQueryBase(result, metadata), timeout(timeout) { | ||
1646 | 32 | } | ||
1647 | 33 | |||
1648 | 34 | TimeoutPreview::~TimeoutPreview() { | ||
1649 | 35 | } | ||
1650 | 36 | |||
1651 | 37 | void TimeoutPreview::cancelled() { | ||
1652 | 38 | } | ||
1653 | 39 | |||
1654 | 40 | #define VARIANT_STR(s) Variant(s.toStdString().c_str()) | ||
1655 | 41 | |||
1656 | 42 | void TimeoutPreview::getVenueDetails(PreviewReplyProxy const& reply) { | ||
1657 | 43 | Result result = PreviewQueryBase::result(); | ||
1658 | 44 | QString urlString(result["uri"].get_string().c_str()); | ||
1659 | 45 | qDebug() << "[Details] GET " << urlString; | ||
1660 | 46 | QUrl url = QUrl(urlString); | ||
1661 | 47 | |||
1662 | 48 | QJsonValuePair response = timeout.get(url, 1); | ||
1663 | 49 | QJsonObject o = response.second.toObject(); | ||
1664 | 50 | |||
1665 | 51 | QString phone = o.value("phone").toString(); | ||
1666 | 52 | QString website = o.value("to_website").toString(); | ||
1667 | 53 | QString address = o.value("address1").toString(); | ||
1668 | 54 | QString postcode = o.value("postcode").toString(); | ||
1669 | 55 | QString city = o.value("city").toString(); | ||
1670 | 56 | QString transport = o.value("transport").toString(); | ||
1671 | 57 | // QString lat = o.value("latitude").toString(); | ||
1672 | 58 | // QString lon = o.value("longitude").toString(); | ||
1673 | 59 | |||
1674 | 60 | PreviewWidget addressLabel("addressLabel", "text"); | ||
1675 | 61 | QString fullAddress = QString("%1 %2").arg(address).arg(postcode); | ||
1676 | 62 | addressLabel.add_attribute_value("text", VARIANT_STR(fullAddress)); | ||
1677 | 63 | |||
1678 | 64 | PreviewWidget contactButtons("contactButtons", "actions"); | ||
1679 | 65 | VariantBuilder contact; | ||
1680 | 66 | QString fullPhone = QString("tel:///%1").arg(phone); | ||
1681 | 67 | |||
1682 | 68 | contact.add_tuple({ | ||
1683 | 69 | {"id", Variant("map")}, | ||
1684 | 70 | {"label", Variant("Map")}, | ||
1685 | 71 | {"uri", Variant(QString("http://m.here.com/#action=search¶ms={\"query\":\"%1,%2 %3\"}") | ||
1686 | 72 | .arg(address).arg(city).arg(postcode).toStdString().c_str())} | ||
1687 | 73 | }); | ||
1688 | 74 | contact.add_tuple({ | ||
1689 | 75 | {"id", Variant("call")}, | ||
1690 | 76 | {"label", Variant("Call")}, | ||
1691 | 77 | {"uri", VARIANT_STR(fullPhone)} | ||
1692 | 78 | }); | ||
1693 | 79 | contact.add_tuple({ | ||
1694 | 80 | {"id", Variant("web")}, | ||
1695 | 81 | {"label", Variant("Website")}, | ||
1696 | 82 | {"uri", VARIANT_STR(website)} | ||
1697 | 83 | }); | ||
1698 | 84 | contactButtons.add_attribute_value("actions", contact.end()); | ||
1699 | 85 | |||
1700 | 86 | PreviewWidget details("details", "text"); | ||
1701 | 87 | details.add_attribute_value("title", Variant("Details")); | ||
1702 | 88 | if (!transport.isEmpty()) { | ||
1703 | 89 | QString detailsText; | ||
1704 | 90 | detailsText.append(QString("<strong>Transport</strong><br />%1").arg(transport)); | ||
1705 | 91 | details.add_attribute_value("text", VARIANT_STR(detailsText)); | ||
1706 | 92 | } | ||
1707 | 93 | |||
1708 | 94 | PreviewWidget actionButtons("actionButtons", "actions"); | ||
1709 | 95 | VariantBuilder actionsBuilder; | ||
1710 | 96 | actionsBuilder.add_tuple({ | ||
1711 | 97 | {"id", Variant("nearby")}, | ||
1712 | 98 | {"label", Variant("Nearby venues")} | ||
1713 | 99 | }); | ||
1714 | 100 | actionsBuilder.add_tuple({ | ||
1715 | 101 | {"id", Variant("share")}, | ||
1716 | 102 | {"label", Variant("Share")} | ||
1717 | 103 | }); | ||
1718 | 104 | actionButtons.add_attribute_value("actions", actionsBuilder.end()); | ||
1719 | 105 | |||
1720 | 106 | // reply->push({addressLabel, contactButtons, details/*transportText*/, actionButtons}); | ||
1721 | 107 | |||
1722 | 108 | //action buttons currently not supported | ||
1723 | 109 | reply->push({addressLabel, contactButtons, details/*transportText*/}); | ||
1724 | 110 | } | ||
1725 | 111 | |||
1726 | 112 | void TimeoutPreview::previewVenue(PreviewReplyProxy const& reply) { | ||
1727 | 113 | Result result = PreviewQueryBase::result(); | ||
1728 | 114 | ColumnLayout one(1); | ||
1729 | 115 | one.add_column({"header", "ratings", "art", | ||
1730 | 116 | "addressLabel", "contactButtons", | ||
1731 | 117 | "timeoutsays", "details"/*"transport"*/, "actionButtons"}); | ||
1732 | 118 | ColumnLayout two(2); | ||
1733 | 119 | two.add_column({"header", "ratings", "art"}); | ||
1734 | 120 | two.add_column({"addressLabel", "contactButtons", "timeoutsays", "details", "actionButtons"}); | ||
1735 | 121 | ColumnLayout three(3); | ||
1736 | 122 | three.add_column({"header", "ratings", "art"}); | ||
1737 | 123 | three.add_column({"contactButtons", "addressLabel", "timeoutsays"}); | ||
1738 | 124 | three.add_column({"actionButtons", "details"}); | ||
1739 | 125 | |||
1740 | 126 | reply->register_layout({one, two, three}); | ||
1741 | 127 | |||
1742 | 128 | PreviewWidget header("header", "header"); | ||
1743 | 129 | header.add_attribute_mapping("title", "title"); | ||
1744 | 130 | header.add_attribute_mapping("subtitle", "subcategory_representation"); | ||
1745 | 131 | |||
1746 | 132 | |||
1747 | 133 | auto hasRating = this->result().contains("average"); | ||
1748 | 134 | auto hasTORating = this->result().contains("editorial_rating"); | ||
1749 | 135 | if (hasRating || hasTORating) { | ||
1750 | 136 | PreviewWidget ratings("ratings", "reviews"); | ||
1751 | 137 | VariantBuilder ratingsBuilder; | ||
1752 | 138 | if (hasTORating) { | ||
1753 | 139 | ratingsBuilder.add_tuple({ | ||
1754 | 140 | {"author", Variant("TimeOut")}, | ||
1755 | 141 | {"rating", result["editorial_rating"]} | ||
1756 | 142 | }); | ||
1757 | 143 | } | ||
1758 | 144 | if (hasRating){ | ||
1759 | 145 | ratingsBuilder.add_tuple({ | ||
1760 | 146 | {"author", Variant("Users")}, | ||
1761 | 147 | {"rating", result["average"]} | ||
1762 | 148 | }); | ||
1763 | 149 | } | ||
1764 | 150 | ratings.add_attribute_value("reviews", ratingsBuilder.end()); | ||
1765 | 151 | reply->push({ratings}); | ||
1766 | 152 | } | ||
1767 | 153 | PreviewWidget art("art", "image"); // id, widget type | ||
1768 | 154 | art.add_attribute_mapping("source", "image"); // widget key, result key | ||
1769 | 155 | |||
1770 | 156 | reply->push({header, art}); | ||
1771 | 157 | |||
1772 | 158 | if (!result["description"].get_string().empty()) { | ||
1773 | 159 | PreviewWidget timeoutsays("timeoutsays", "text"); | ||
1774 | 160 | timeoutsays.add_attribute_value("title", Variant("TimeOut says")); | ||
1775 | 161 | timeoutsays.add_attribute_mapping("text", "description"); | ||
1776 | 162 | reply->push({timeoutsays}); | ||
1777 | 163 | } | ||
1778 | 164 | |||
1779 | 165 | getVenueDetails(reply); | ||
1780 | 166 | } | ||
1781 | 167 | |||
1782 | 168 | void TimeoutPreview::getEventDetails(PreviewReplyProxy const& reply) { | ||
1783 | 169 | Result result = PreviewQueryBase::result(); | ||
1784 | 170 | QString urlString(result["uri"].get_string().c_str()); | ||
1785 | 171 | qDebug() << "[Details] GET " << urlString; | ||
1786 | 172 | QUrl url = QUrl(urlString); | ||
1787 | 173 | |||
1788 | 174 | QJsonValuePair response = timeout.get(url, 1); | ||
1789 | 175 | QJsonObject o = response.second.toObject(); | ||
1790 | 176 | |||
1791 | 177 | QString phone = o.value("phone").toString(); | ||
1792 | 178 | QString website = o.value("to_website").toString(); | ||
1793 | 179 | QString venueUrl = o.value("venue_urls").toArray()[0].toString(); | ||
1794 | 180 | QString startDate = o.value("start_date").toString(); | ||
1795 | 181 | QString endDate = o.value("end_date").toString(); | ||
1796 | 182 | QString price = o.value("price").toString(); | ||
1797 | 183 | QString related = o.value("related_items_url").toString(); | ||
1798 | 184 | QString affinitiesUrl = o.value("affinities_url").toString(); | ||
1799 | 185 | QString occurrencesUrl = o.value("occurrences_url").toString(); | ||
1800 | 186 | // occurrence_periods_url | ||
1801 | 187 | //QString bookingWeb = o.value("booking_website").toString(); | ||
1802 | 188 | // posted_at_date | ||
1803 | 189 | // annotatino (same as description?) | ||
1804 | 190 | |||
1805 | 191 | if (o.contains("to_opinion")) { | ||
1806 | 192 | if (o.value("to_opinion").toString() == "critics_choice") { | ||
1807 | 193 | PreviewWidget opinion("opinion", "text"); | ||
1808 | 194 | opinion.add_attribute_value("text", Variant("✔ Critics choice")); | ||
1809 | 195 | |||
1810 | 196 | reply->push({opinion}); | ||
1811 | 197 | } | ||
1812 | 198 | } | ||
1813 | 199 | |||
1814 | 200 | qDebug() << "[Event venue] GET " << urlString; | ||
1815 | 201 | response = timeout.get(QUrl(venueUrl), 1); | ||
1816 | 202 | o = response.second.toObject(); | ||
1817 | 203 | |||
1818 | 204 | QString venueName = o.value("name").toString(); | ||
1819 | 205 | QString address = o.value("address1").toString(); | ||
1820 | 206 | QString postcode = o.value("postcode").toString(); | ||
1821 | 207 | QString city = o.value("city").toString(); | ||
1822 | 208 | QString transport = o.value("transport").toString(); | ||
1823 | 209 | |||
1824 | 210 | PreviewWidget addressLabel("addressLabel", "text"); | ||
1825 | 211 | addressLabel.add_attribute_value("title", VARIANT_STR(venueName)); | ||
1826 | 212 | QString fullAddress = QString("%1 %2").arg(address).arg(postcode); | ||
1827 | 213 | addressLabel.add_attribute_value("text", VARIANT_STR(fullAddress)); | ||
1828 | 214 | |||
1829 | 215 | // get occurrencesUrl here | ||
1830 | 216 | QString showtimes = "TBD"; | ||
1831 | 217 | |||
1832 | 218 | PreviewWidget contactButtons("contactButtons", "actions"); | ||
1833 | 219 | VariantBuilder contact; | ||
1834 | 220 | QString fullPhone = QString("tel:///%1").arg(phone); | ||
1835 | 221 | contact.add_tuple({ | ||
1836 | 222 | {"id", Variant("call")}, | ||
1837 | 223 | {"label", Variant("Call")}, | ||
1838 | 224 | {"uri", VARIANT_STR(fullPhone)} | ||
1839 | 225 | }); | ||
1840 | 226 | contact.add_tuple({ | ||
1841 | 227 | {"id", Variant("map")}, | ||
1842 | 228 | {"label", Variant("Map")}, | ||
1843 | 229 | {"uri", Variant(QString("http://m.here.com/#action=search¶ms={\"query\":\"%1,%2 %3\"}") | ||
1844 | 230 | .arg(address).arg(city).arg(postcode).toStdString().c_str())} | ||
1845 | 231 | }); | ||
1846 | 232 | contact.add_tuple({ | ||
1847 | 233 | {"id", Variant("web")}, | ||
1848 | 234 | {"label", Variant("Website")}, | ||
1849 | 235 | {"uri", VARIANT_STR(website)} | ||
1850 | 236 | }); | ||
1851 | 237 | contactButtons.add_attribute_value("actions", contact.end()); | ||
1852 | 238 | |||
1853 | 239 | PreviewWidget details("details", "text"); | ||
1854 | 240 | details.add_attribute_value("title", Variant("Details")); | ||
1855 | 241 | QString detailsText; | ||
1856 | 242 | // detailsText.append(QString("<strong>Showtimes</strong><br />%1<br />").arg(showtimes)); | ||
1857 | 243 | if (!price.isEmpty()) | ||
1858 | 244 | detailsText.append(QString("<strong>Price</strong><br />%1<br />").arg(price)); | ||
1859 | 245 | if (!transport.isEmpty()) | ||
1860 | 246 | detailsText.append(QString("<strong>Transport</strong><br />%1").arg(transport)); | ||
1861 | 247 | details.add_attribute_value("text", VARIANT_STR(detailsText)); | ||
1862 | 248 | |||
1863 | 249 | PreviewWidget actionButtons("actionButtons", "actions"); | ||
1864 | 250 | VariantBuilder actionsBuilder; | ||
1865 | 251 | actionsBuilder.add_tuple({ | ||
1866 | 252 | {"id", Variant("nearby")}, | ||
1867 | 253 | {"label", Variant("Nearby venues")} | ||
1868 | 254 | }); | ||
1869 | 255 | actionsBuilder.add_tuple({ | ||
1870 | 256 | {"id", Variant("share")}, | ||
1871 | 257 | {"label", Variant("Share")} | ||
1872 | 258 | }); | ||
1873 | 259 | actionButtons.add_attribute_value("actions", actionsBuilder.end()); | ||
1874 | 260 | |||
1875 | 261 | //reply->push({addressLabel, contactButtons, details, actionButtons}); | ||
1876 | 262 | reply->push({addressLabel, contactButtons, details}); | ||
1877 | 263 | } | ||
1878 | 264 | |||
1879 | 265 | void TimeoutPreview::previewEvent(PreviewReplyProxy const& reply) { | ||
1880 | 266 | Result result = PreviewQueryBase::result(); | ||
1881 | 267 | ColumnLayout one(1); | ||
1882 | 268 | one.add_column({"header", "ratings", "art", | ||
1883 | 269 | "addressLabel", "contactButtons", | ||
1884 | 270 | "timeoutsays", "details", "actionButtons"}); | ||
1885 | 271 | |||
1886 | 272 | ColumnLayout two(2); | ||
1887 | 273 | two.add_column({"header", "ratings", "art", | ||
1888 | 274 | "addressLabel"}); | ||
1889 | 275 | two.add_column({"contactButtons", | ||
1890 | 276 | "timeoutsays", "details", "actionButtons"}); | ||
1891 | 277 | |||
1892 | 278 | |||
1893 | 279 | ColumnLayout three(3); | ||
1894 | 280 | three.add_column({"header", "ratings", "art"}); | ||
1895 | 281 | three.add_column({"addressLabel", "contactButtons", | ||
1896 | 282 | "timeoutsays"}); | ||
1897 | 283 | three.add_column({"details", "actionButtons"}); | ||
1898 | 284 | reply->register_layout({one, two, three}); | ||
1899 | 285 | |||
1900 | 286 | PreviewWidget header("header", "header"); | ||
1901 | 287 | header.add_attribute_mapping("title", "title"); | ||
1902 | 288 | header.add_attribute_mapping("subtitle", "category_representation"); | ||
1903 | 289 | |||
1904 | 290 | auto hasRating = this->result().contains("average"); | ||
1905 | 291 | auto hasTORating = this->result().contains("editorial_rating"); | ||
1906 | 292 | if (hasRating || hasTORating) { | ||
1907 | 293 | PreviewWidget ratings("ratings", "reviews"); | ||
1908 | 294 | VariantBuilder ratingsBuilder; | ||
1909 | 295 | if (hasTORating) { | ||
1910 | 296 | ratingsBuilder.add_tuple({ | ||
1911 | 297 | {"author", Variant("TimeOut")}, | ||
1912 | 298 | {"rating", result["editorial_rating"]} | ||
1913 | 299 | }); | ||
1914 | 300 | } | ||
1915 | 301 | if (hasRating){ | ||
1916 | 302 | ratingsBuilder.add_tuple({ | ||
1917 | 303 | {"author", Variant("Users")}, | ||
1918 | 304 | {"rating", result["average"]} | ||
1919 | 305 | }); | ||
1920 | 306 | } | ||
1921 | 307 | ratings.add_attribute_value("reviews", ratingsBuilder.end()); | ||
1922 | 308 | reply->push({ratings}); | ||
1923 | 309 | } | ||
1924 | 310 | PreviewWidget art("art", "image"); | ||
1925 | 311 | art.add_attribute_mapping("source", "image"); | ||
1926 | 312 | |||
1927 | 313 | reply->push({header, art}); | ||
1928 | 314 | |||
1929 | 315 | if (!result["description"].get_string().empty()) { | ||
1930 | 316 | PreviewWidget timeoutsays("timeoutsays", "text"); | ||
1931 | 317 | timeoutsays.add_attribute_value("title", Variant("TimeOut says")); | ||
1932 | 318 | timeoutsays.add_attribute_mapping("text", "description"); | ||
1933 | 319 | reply->push({timeoutsays}); | ||
1934 | 320 | } | ||
1935 | 321 | |||
1936 | 322 | getEventDetails(reply); | ||
1937 | 323 | } | ||
1938 | 324 | |||
1939 | 325 | void TimeoutPreview::previewFilm(PreviewReplyProxy const& reply) { | ||
1940 | 326 | Result result = PreviewQueryBase::result(); | ||
1941 | 327 | |||
1942 | 328 | ColumnLayout one(1); | ||
1943 | 329 | one.add_column({"header", "ratings", "art","FilmButtons", "timeoutsays", "timeoutsays"}); | ||
1944 | 330 | |||
1945 | 331 | ColumnLayout two(2); | ||
1946 | 332 | two.add_column({"header", "ratings", "art"}); | ||
1947 | 333 | two.add_column({"FilmButtons", "timeoutsays"}); | ||
1948 | 334 | |||
1949 | 335 | ColumnLayout three(3); | ||
1950 | 336 | three.add_column({"art","FilmButtons"}); | ||
1951 | 337 | three.add_column({"header", "ratings"}); | ||
1952 | 338 | three.add_column({"timeoutsays", "timeoutsays"}); | ||
1953 | 339 | |||
1954 | 340 | reply->register_layout({one, two, three}); | ||
1955 | 341 | |||
1956 | 342 | PreviewWidget header("header", "header"); | ||
1957 | 343 | header.add_attribute_mapping("title", "title"); | ||
1958 | 344 | header.add_attribute_mapping("subtitle", "category_representation"); | ||
1959 | 345 | |||
1960 | 346 | auto hasRating = this->result().contains("average"); | ||
1961 | 347 | auto hasTORating = this->result().contains("editorial_rating"); | ||
1962 | 348 | |||
1963 | 349 | if (hasRating || hasTORating) { | ||
1964 | 350 | PreviewWidget ratings("ratings", "reviews"); | ||
1965 | 351 | VariantBuilder ratingsBuilder; | ||
1966 | 352 | if (hasTORating) { | ||
1967 | 353 | ratingsBuilder.add_tuple({ | ||
1968 | 354 | {"author", Variant("TimeOut")}, | ||
1969 | 355 | {"rating", result["editorial_rating"]} | ||
1970 | 356 | }); | ||
1971 | 357 | } | ||
1972 | 358 | if (hasRating){ | ||
1973 | 359 | ratingsBuilder.add_tuple({ | ||
1974 | 360 | {"author", Variant("Users")}, | ||
1975 | 361 | {"rating", result["average"]} | ||
1976 | 362 | }); | ||
1977 | 363 | } | ||
1978 | 364 | ratings.add_attribute_value("reviews", ratingsBuilder.end()); | ||
1979 | 365 | reply->push({ratings}); | ||
1980 | 366 | } | ||
1981 | 367 | |||
1982 | 368 | PreviewWidget art("art", "image"); | ||
1983 | 369 | art.add_attribute_mapping("source", "image"); | ||
1984 | 370 | |||
1985 | 371 | reply->push({header, art}); | ||
1986 | 372 | |||
1987 | 373 | if (!result["description"].get_string().empty()) { | ||
1988 | 374 | PreviewWidget timeoutsays("timeoutsays", "text"); | ||
1989 | 375 | timeoutsays.add_attribute_value("title", Variant("TimeOut says")); | ||
1990 | 376 | timeoutsays.add_attribute_mapping("text", "description"); | ||
1991 | 377 | reply->push({timeoutsays}); | ||
1992 | 378 | } | ||
1993 | 379 | |||
1994 | 380 | QString urlString(result["uri"].get_string().c_str()); | ||
1995 | 381 | qDebug() << "[Details] GET " << urlString; | ||
1996 | 382 | QUrl url = QUrl(urlString); | ||
1997 | 383 | |||
1998 | 384 | QJsonValuePair response = timeout.get(url, 1); | ||
1999 | 385 | QJsonObject o = response.second.toObject(); | ||
2000 | 386 | |||
2001 | 387 | QString website = o.value("to_website").toString(); | ||
2002 | 388 | if (!website.isEmpty()){ | ||
2003 | 389 | PreviewWidget filmButtons("FilmButtons", "actions"); | ||
2004 | 390 | VariantBuilder filmAction; | ||
2005 | 391 | filmAction.add_tuple({ | ||
2006 | 392 | {"id", Variant("web")}, | ||
2007 | 393 | {"label", Variant("More")}, | ||
2008 | 394 | {"uri", VARIANT_STR(website)} | ||
2009 | 395 | }); | ||
2010 | 396 | filmButtons.add_attribute_value("actions", filmAction.end()); | ||
2011 | 397 | reply->push({filmButtons}); | ||
2012 | 398 | } | ||
2013 | 399 | |||
2014 | 400 | } | ||
2015 | 401 | |||
2016 | 402 | void TimeoutPreview::run(PreviewReplyProxy const& reply) { | ||
2017 | 403 | Result result = PreviewQueryBase::result(); | ||
2018 | 404 | std::string type = result["type"].get_string(); | ||
2019 | 405 | qDebug() << "Previewing: " << QString(type.c_str()); | ||
2020 | 406 | if (type == "venue") { | ||
2021 | 407 | previewVenue(reply); | ||
2022 | 408 | } else if (type == "event") { | ||
2023 | 409 | previewEvent(reply); | ||
2024 | 410 | } else if (type == "film") { | ||
2025 | 411 | previewFilm(reply); | ||
2026 | 412 | } | ||
2027 | 413 | } | ||
2028 | 0 | 414 | ||
2029 | === added file 'src/TimeOut-preview.h' | |||
2030 | --- src/TimeOut-preview.h 1970-01-01 00:00:00 +0000 | |||
2031 | +++ src/TimeOut-preview.h 2014-09-24 10:37:38 +0000 | |||
2032 | @@ -0,0 +1,46 @@ | |||
2033 | 1 | /* | ||
2034 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2035 | 3 | * Copyright 2014 Canonical Ltd. | ||
2036 | 4 | * | ||
2037 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2038 | 6 | * under the terms of the GNU General Public License as published by | ||
2039 | 7 | * the Free Software Foundation. | ||
2040 | 8 | * | ||
2041 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2042 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2043 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2044 | 12 | * See the GNU General Public License for more details. | ||
2045 | 13 | * | ||
2046 | 14 | * You should have received a copy of the GNU General Public License | ||
2047 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2048 | 16 | */ | ||
2049 | 17 | |||
2050 | 18 | #ifndef TIMEOUT_PREVIEW_H | ||
2051 | 19 | #define TIMEOUT_PREVIEW_H | ||
2052 | 20 | |||
2053 | 21 | #include "TimeOut-client.h" | ||
2054 | 22 | |||
2055 | 23 | #include <unity/scopes/PreviewQueryBase.h> | ||
2056 | 24 | #include <unity/scopes/Result.h> | ||
2057 | 25 | |||
2058 | 26 | using namespace unity::scopes; | ||
2059 | 27 | |||
2060 | 28 | class TimeoutPreview : public PreviewQueryBase | ||
2061 | 29 | { | ||
2062 | 30 | public: | ||
2063 | 31 | TimeoutPreview(Result const&, ActionMetadata const&, TimeOut const&); | ||
2064 | 32 | ~TimeoutPreview(); | ||
2065 | 33 | |||
2066 | 34 | virtual void cancelled() override; | ||
2067 | 35 | virtual void run(PreviewReplyProxy const& reply) override; | ||
2068 | 36 | void getVenueDetails(PreviewReplyProxy const& reply); | ||
2069 | 37 | void getEventDetails(PreviewReplyProxy const& reply); | ||
2070 | 38 | void previewVenue(PreviewReplyProxy const& reply); | ||
2071 | 39 | void previewEvent(PreviewReplyProxy const& reply); | ||
2072 | 40 | void previewFilm(PreviewReplyProxy const& reply); | ||
2073 | 41 | |||
2074 | 42 | private: | ||
2075 | 43 | const TimeOut timeout; | ||
2076 | 44 | }; | ||
2077 | 45 | |||
2078 | 46 | #endif | ||
2079 | 0 | 47 | ||
2080 | === added file 'src/TimeOut-query.cpp' | |||
2081 | --- src/TimeOut-query.cpp 1970-01-01 00:00:00 +0000 | |||
2082 | +++ src/TimeOut-query.cpp 2014-09-24 10:37:38 +0000 | |||
2083 | @@ -0,0 +1,491 @@ | |||
2084 | 1 | /* | ||
2085 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2086 | 3 | * Copyright 2014 Canonical Ltd. | ||
2087 | 4 | * | ||
2088 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2089 | 6 | * under the terms of the GNU General Public License as published by | ||
2090 | 7 | * the Free Software Foundation. | ||
2091 | 8 | * | ||
2092 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2093 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2094 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2095 | 12 | * See the GNU General Public License for more details. | ||
2096 | 13 | * | ||
2097 | 14 | * You should have received a copy of the GNU General Public License | ||
2098 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2099 | 16 | */ | ||
2100 | 17 | |||
2101 | 18 | #include "TimeOut-query.h" | ||
2102 | 19 | #include "TimeOut-client.h" | ||
2103 | 20 | |||
2104 | 21 | #include <unity/scopes/Annotation.h> | ||
2105 | 22 | #include <unity/scopes/CategorisedResult.h> | ||
2106 | 23 | #include <unity/scopes/CategoryRenderer.h> | ||
2107 | 24 | #include <unity/scopes/QueryBase.h> | ||
2108 | 25 | #include <unity/scopes/SearchReply.h> | ||
2109 | 26 | #include <unity/scopes/Department.h> | ||
2110 | 27 | #include <unity/scopes/VariantBuilder.h> | ||
2111 | 28 | |||
2112 | 29 | using namespace Qt; | ||
2113 | 30 | using namespace unity::scopes; | ||
2114 | 31 | |||
2115 | 32 | std::string JOURNAL; | ||
2116 | 33 | std::string WIDE_ART; | ||
2117 | 34 | std::string HORIZONTAL_LIST; | ||
2118 | 35 | std::string MEDIUM_GRID; | ||
2119 | 36 | std::string LARGE_GRID; | ||
2120 | 37 | std::string CAROUSEL; | ||
2121 | 38 | |||
2122 | 39 | const QString imageWidth = QString("{width}"); | ||
2123 | 40 | const QString imageHeight = QString("{height}"); | ||
2124 | 41 | |||
2125 | 42 | //avoid registering multiple depts | ||
2126 | 43 | std::set<QString> Deptset; | ||
2127 | 44 | |||
2128 | 45 | QString readFile(QString path) { | ||
2129 | 46 | QFile file(path); | ||
2130 | 47 | file.open(QIODevice::ReadOnly | QIODevice::Text); | ||
2131 | 48 | QString data = file.readAll(); | ||
2132 | 49 | file.close(); | ||
2133 | 50 | return data; | ||
2134 | 51 | } | ||
2135 | 52 | |||
2136 | 53 | std::string TimeoutQuery::getRenderer(QString name) { | ||
2137 | 54 | QString path = QString("%1/renderer/%2.json").arg(scopePath_).arg(name); | ||
2138 | 55 | qDebug() << "loading renderer " << path; | ||
2139 | 56 | QString renderer = readFile(path); | ||
2140 | 57 | return renderer.toStdString(); | ||
2141 | 58 | } | ||
2142 | 59 | |||
2143 | 60 | TimeoutQuery::TimeoutQuery(CannedQuery const& query, SearchMetadata const& metadata, TimeOut &timeout, QString scope_dir) | ||
2144 | 61 | : SearchQueryBase(query, metadata), timeout(timeout), scopePath_(scope_dir) { | ||
2145 | 62 | JOURNAL = getRenderer("vjournal"); | ||
2146 | 63 | WIDE_ART = getRenderer("wide-art"); | ||
2147 | 64 | MEDIUM_GRID = getRenderer("medium-grid"); | ||
2148 | 65 | LARGE_GRID = getRenderer("large-grid"); | ||
2149 | 66 | CAROUSEL = getRenderer("carousel"); | ||
2150 | 67 | HORIZONTAL_LIST = getRenderer("horizontal-list"); | ||
2151 | 68 | } | ||
2152 | 69 | |||
2153 | 70 | TimeoutQuery::~TimeoutQuery() { | ||
2154 | 71 | |||
2155 | 72 | } | ||
2156 | 73 | |||
2157 | 74 | void TimeoutQuery::cancelled() { | ||
2158 | 75 | } | ||
2159 | 76 | |||
2160 | 77 | void set(CategorisedResult &result, std::string &key, QString &value) { | ||
2161 | 78 | result[key] = value.toStdString(); | ||
2162 | 79 | } | ||
2163 | 80 | |||
2164 | 81 | std::string reformat(QString mytext){ | ||
2165 | 82 | QTextDocument text; | ||
2166 | 83 | text.setHtml(mytext); | ||
2167 | 84 | auto newText =text.toPlainText().toStdString(); | ||
2168 | 85 | return newText; | ||
2169 | 86 | } | ||
2170 | 87 | |||
2171 | 88 | #define SET_RESULT(key) result[key] = o.value(key).toString().toStdString() | ||
2172 | 89 | #define SET_RESULT_INT(key) result[key] = o.value(key).toInt(0) | ||
2173 | 90 | #define SET_RESULT_REMAP(apikey, key) result[key] = o.value(apikey).toString().toStdString() | ||
2174 | 91 | #define SET_RESULT_FROM_JSON(apikey, key, json) result[key] = json.value(apikey).toString().toStdString() | ||
2175 | 92 | |||
2176 | 93 | void getResultDetailsFromJson(QJsonObject const& o, CategorisedResult &result) { | ||
2177 | 94 | SET_RESULT("uid"); | ||
2178 | 95 | SET_RESULT("id"); | ||
2179 | 96 | SET_RESULT("category_representation"); | ||
2180 | 97 | SET_RESULT("subcategory_representation"); | ||
2181 | 98 | |||
2182 | 99 | //remove html special characters from the description | ||
2183 | 100 | auto formatted_text = reformat(o.value("description").toString()); | ||
2184 | 101 | result["description"]=formatted_text; | ||
2185 | 102 | |||
2186 | 103 | SET_RESULT_REMAP("to_website", "web"); | ||
2187 | 104 | if (o.contains("editorial_rating")) { | ||
2188 | 105 | SET_RESULT_INT("editorial_rating"); | ||
2189 | 106 | } | ||
2190 | 107 | if (o.contains("user_ratings_summary")) { | ||
2191 | 108 | QJsonObject ratings = o.value("user_ratings_summary").toObject(); | ||
2192 | 109 | SET_RESULT_FROM_JSON("average", "average", ratings); | ||
2193 | 110 | SET_RESULT_FROM_JSON("count", "count", ratings); | ||
2194 | 111 | } | ||
2195 | 112 | } | ||
2196 | 113 | |||
2197 | 114 | #define SET_SIZE(pattern, w, h) pattern\ | ||
2198 | 115 | .replace(imageWidth, QString::number(w))\ | ||
2199 | 116 | .replace(imageHeight, QString::number(h))\ | ||
2200 | 117 | .toStdString() | ||
2201 | 118 | |||
2202 | 119 | void getResultFromJson(QJsonArray::iterator const& it, CategorisedResult &result) { | ||
2203 | 120 | QJsonObject o = (*it).toObject(); | ||
2204 | 121 | |||
2205 | 122 | SET_RESULT_REMAP("url", "uri"); | ||
2206 | 123 | SET_RESULT_REMAP("name", "title"); | ||
2207 | 124 | QJsonObject image = o.value("image").toObject(); | ||
2208 | 125 | if (image.contains("url_pattern")) { | ||
2209 | 126 | QJsonObject pattern = image.value("url_pattern").toObject(); | ||
2210 | 127 | QString urlPattern = pattern.value("value").toString(); | ||
2211 | 128 | result["image"] = SET_SIZE(urlPattern, 480, 360); | ||
2212 | 129 | result["image-large"] = SET_SIZE(urlPattern, 800, 600); | ||
2213 | 130 | result["image-small"] = SET_SIZE(urlPattern, 320, 240); | ||
2214 | 131 | } else { | ||
2215 | 132 | SET_RESULT_FROM_JSON("url", "image", image); | ||
2216 | 133 | } | ||
2217 | 134 | |||
2218 | 135 | if (o.contains("type")) { | ||
2219 | 136 | qDebug() << "Item contains type"; | ||
2220 | 137 | QString type = o.value("type").toString(); | ||
2221 | 138 | result["type"] = type.toStdString(); | ||
2222 | 139 | if (type != "curated") { | ||
2223 | 140 | getResultDetailsFromJson(o, result); | ||
2224 | 141 | } else { | ||
2225 | 142 | //this creates a link to a department when you click on a result | ||
2226 | 143 | qDebug() << "Item is a link to a category"; | ||
2227 | 144 | auto uri = o.value("url").toString(); | ||
2228 | 145 | CannedQuery catheader_query((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString(), "", | ||
2229 | 146 | uri.toStdString()); | ||
2230 | 147 | result.set_uri(catheader_query.to_uri()); | ||
2231 | 148 | } | ||
2232 | 149 | } | ||
2233 | 150 | } | ||
2234 | 151 | |||
2235 | 152 | /* | ||
2236 | 153 | This is hardcoded here only temporarily for alternate content surfacing. For instance, | ||
2237 | 154 | in "Restaurants and Cafes" category we used to show the list of curated lists. Being | ||
2238 | 155 | temporarily limited by technical reasons, instead of showing those (which would not yet | ||
2239 | 156 | open proper lists of items), we show selected subcategory from given category when surfacing." | ||
2240 | 157 | */ | ||
2241 | 158 | static const QMap<QString, QString> ALTERNATE_SURFACING { | ||
2242 | 159 | { | ||
2243 | 160 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/restaurants_caf_s?locale=en-GB", | ||
2244 | 161 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/food+%26+drink/sunday_roasts_mobile?locale=en-GB" | ||
2245 | 162 | }, | ||
2246 | 163 | { | ||
2247 | 164 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/bars_pubs?locale=en-GB", | ||
2248 | 165 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/food+%26+drink/lon_en_20120718_ipad_cocktailbars?locale=en-GB" | ||
2249 | 166 | }, | ||
2250 | 167 | { | ||
2251 | 168 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/things_to_do?locale=en-GB", | ||
2252 | 169 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/things+to+do/london_hot_list?locale=en-GB" | ||
2253 | 170 | }, | ||
2254 | 171 | { | ||
2255 | 172 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/art?locale=en-GB", | ||
2256 | 173 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/art+%26+culture/art_best_new_art?locale=en-GB" | ||
2257 | 174 | }, | ||
2258 | 175 | { | ||
2259 | 176 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/theatre_dance?locale=en-GB", | ||
2260 | 177 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/art+%26+culture/theatre_critics_choice_new_shows?locale=en-GB" | ||
2261 | 178 | }, | ||
2262 | 179 | { | ||
2263 | 180 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/muisc_nightlife?locale=en-GB", | ||
2264 | 181 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/music+%26+nightlife/clubs_app?locale=en-GB" | ||
2265 | 182 | }, | ||
2266 | 183 | { | ||
2267 | 184 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/editorial+lists/shopping_style?locale=en-GB", | ||
2268 | 185 | "http://graffiti.timeout.com/v1/mobile/uk-london/curateds/shopping+%26+lifestyle/department_stores?locale=en-GB" | ||
2269 | 186 | } | ||
2270 | 187 | }; | ||
2271 | 188 | |||
2272 | 189 | #define FOREACH_JSON(it, results) for (QJsonArray::iterator it = results.begin(); it != results.end(); ++it) | ||
2273 | 190 | |||
2274 | 191 | void TimeoutQuery::getGeneric(TimeOut const& timeout, QString &url, std::string &categoryJson, | ||
2275 | 192 | QString &id, QString &title, SearchReplyProxy const& reply) { | ||
2276 | 193 | |||
2277 | 194 | qDebug() << "category id is " << id; | ||
2278 | 195 | CannedQuery catheader_query((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString(), "", | ||
2279 | 196 | url.toStdString()); | ||
2280 | 197 | |||
2281 | 198 | CategoryRenderer renderer(categoryJson); | ||
2282 | 199 | Category::SCPtr category; | ||
2283 | 200 | |||
2284 | 201 | if (title.isEmpty()) { | ||
2285 | 202 | category= reply->register_category( | ||
2286 | 203 | id.toStdString(), title.toStdString(), "", renderer); | ||
2287 | 204 | } else { | ||
2288 | 205 | category= reply->register_category( | ||
2289 | 206 | id.toStdString(), title.toStdString(), "",catheader_query, renderer); | ||
2290 | 207 | } | ||
2291 | 208 | |||
2292 | 209 | QJsonValuePair response = timeout.get(QUrl(url), 1); | ||
2293 | 210 | QJsonArray results = BODY(response); | ||
2294 | 211 | |||
2295 | 212 | FOREACH_JSON(json, results) { | ||
2296 | 213 | CategorisedResult result(category); | ||
2297 | 214 | getResultFromJson(json, result); | ||
2298 | 215 | if (!reply->push(result)) break; | ||
2299 | 216 | } | ||
2300 | 217 | } | ||
2301 | 218 | |||
2302 | 219 | void TimeoutQuery::getEditorLists(TimeOut const& timeout, SearchReplyProxy const& reply) { | ||
2303 | 220 | QJsonArray results = timeout.getEditorLists(1); | ||
2304 | 221 | FOREACH_JSON(json, results) { | ||
2305 | 222 | QJsonObject o = (*json).toObject(); | ||
2306 | 223 | QString uid = o.value("uid").toString(); | ||
2307 | 224 | if (!(uid.contains("things_to_do") || uid.contains(MAD_TTODO))) | ||
2308 | 225 | continue; | ||
2309 | 226 | QString listName = o.value("name").toString(); | ||
2310 | 227 | QString name = listName; | ||
2311 | 228 | QString url = o.value("url").toString(); | ||
2312 | 229 | if (uid.contains(MAD_TTODO)) uid =+ "things_to_do"; | ||
2313 | 230 | std::string category = WIDE_ART; | ||
2314 | 231 | getGeneric(timeout, url, category, uid, name, reply); | ||
2315 | 232 | } | ||
2316 | 233 | |||
2317 | 234 | FOREACH_JSON(json, results) { | ||
2318 | 235 | QJsonObject o = (*json).toObject(); | ||
2319 | 236 | QString uid = o.value("uid").toString(); | ||
2320 | 237 | if (uid.contains("things_to_do")) | ||
2321 | 238 | continue; | ||
2322 | 239 | QString listName = o.value("name").toString(); | ||
2323 | 240 | QString name = listName; | ||
2324 | 241 | QString url = o.value("url").toString(); | ||
2325 | 242 | if (uid.contains(MAD_BAR)) uid =+ "bars"; | ||
2326 | 243 | if (uid.contains(MAD_RESTAURANTS)) uid =+ "restaurants"; | ||
2327 | 244 | if (uid.contains(MAD_SHOPPING)) uid =+ "shopping"; | ||
2328 | 245 | qDebug() << "Category id is " << uid; | ||
2329 | 246 | |||
2330 | 247 | std::string category = MEDIUM_GRID; | ||
2331 | 248 | getGeneric(timeout, url, category, uid, name, reply); | ||
2332 | 249 | } | ||
2333 | 250 | } | ||
2334 | 251 | |||
2335 | 252 | void TimeoutQuery::getCitySurface(TimeOut timeout, SearchReplyProxy reply) { | ||
2336 | 253 | CategoryRenderer renderer(JOURNAL); | ||
2337 | 254 | auto citiesCat = reply->register_category("cities", "", "", renderer); | ||
2338 | 255 | auto citiesArt =timeout.getCityLogos(); | ||
2339 | 256 | auto cities = timeout.getSupportedCities(); | ||
2340 | 257 | for (unsigned int i = 0; i < cities.size(); i++) { | ||
2341 | 258 | CategorisedResult result(citiesCat); | ||
2342 | 259 | CannedQuery city_query((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString(), "", | ||
2343 | 260 | ("city:"+ cities[i].url).toStdString()); | ||
2344 | 261 | result.set_uri(city_query.to_uri()); | ||
2345 | 262 | QString city_name = cities[i].name; | ||
2346 | 263 | result["image-small"]=citiesArt[city_name].toStdString(); | ||
2347 | 264 | result["title"]=city_name.toStdString(); | ||
2348 | 265 | |||
2349 | 266 | reply->push(result); | ||
2350 | 267 | } | ||
2351 | 268 | |||
2352 | 269 | } | ||
2353 | 270 | void TimeoutQuery::getEditorPicks(TimeOut const& timeout, SearchReplyProxy const& reply) { | ||
2354 | 271 | CategoryRenderer renderer(HORIZONTAL_LIST); | ||
2355 | 272 | auto editorPicks = reply->register_category("editor-picks", "", "", renderer); | ||
2356 | 273 | QJsonArray results = timeout.getEditorPicks(1); | ||
2357 | 274 | |||
2358 | 275 | qDebug() << "Got editors picks"; | ||
2359 | 276 | FOREACH_JSON(json, results) { | ||
2360 | 277 | QJsonObject o = (*json).toObject(); | ||
2361 | 278 | QString type = o.value("type").toString(); | ||
2362 | 279 | // FIXME filtering out type:curated for now. Needs activation. | ||
2363 | 280 | if (type == "curated") continue; | ||
2364 | 281 | |||
2365 | 282 | CategorisedResult result(editorPicks); | ||
2366 | 283 | getResultFromJson(json, result); | ||
2367 | 284 | if (!reply->push(result)) break; | ||
2368 | 285 | } | ||
2369 | 286 | } | ||
2370 | 287 | |||
2371 | 288 | void TimeoutQuery::search(TimeOut const& timeout, SearchReplyProxy const& reply) { | ||
2372 | 289 | CannedQuery cannedQuery = SearchQueryBase::query(); | ||
2373 | 290 | QString query = QString::fromStdString(cannedQuery.query_string()); | ||
2374 | 291 | QString title = QString("Results for %1:").arg(query); | ||
2375 | 292 | |||
2376 | 293 | CategoryRenderer renderer(JOURNAL); | ||
2377 | 294 | auto search = reply->register_category("search", title.toStdString(), "", renderer); | ||
2378 | 295 | |||
2379 | 296 | QJsonArray results = timeout.search(query, 1); | ||
2380 | 297 | FOREACH_JSON(json, results) { | ||
2381 | 298 | QJsonObject o = (*json).toObject(); | ||
2382 | 299 | QString type = o.value("type").toString(); | ||
2383 | 300 | |||
2384 | 301 | CategorisedResult result(search); | ||
2385 | 302 | getResultFromJson(json, result); | ||
2386 | 303 | if (!reply->push(result)) break; | ||
2387 | 304 | } | ||
2388 | 305 | } | ||
2389 | 306 | |||
2390 | 307 | const int MAX_DEPT_NAME = 45; | ||
2391 | 308 | |||
2392 | 309 | void setSubdepartments(TimeOut const& timeout, Department::SPtr const& parent, QString &/*id*/, | ||
2393 | 310 | QString &/*title*/, QUrl const& url, SearchReplyProxy const& /*reply*/) { | ||
2394 | 311 | DepartmentList depts; | ||
2395 | 312 | |||
2396 | 313 | QJsonValuePair response = timeout.get(QUrl(url), 1); | ||
2397 | 314 | QJsonArray results = BODY(response); | ||
2398 | 315 | |||
2399 | 316 | FOREACH_JSON(json, results) { | ||
2400 | 317 | QJsonObject o = (*json).toObject(); | ||
2401 | 318 | QString uid = o.value("uid").toString(); | ||
2402 | 319 | QString name = o.value("name").toString(); | ||
2403 | 320 | QString url = o.value("url").toString(); | ||
2404 | 321 | QString type = o.value("type").toString(); | ||
2405 | 322 | |||
2406 | 323 | if (name.length() > MAX_DEPT_NAME) { | ||
2407 | 324 | name = name.left(MAX_DEPT_NAME) + "..."; | ||
2408 | 325 | } | ||
2409 | 326 | |||
2410 | 327 | if (type == "curated") { | ||
2411 | 328 | CannedQuery query((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString()); | ||
2412 | 329 | if (Deptset.find(url) != Deptset.end()) { | ||
2413 | 330 | qDebug()<<"duplicated dept " << url; | ||
2414 | 331 | continue; | ||
2415 | 332 | } | ||
2416 | 333 | Deptset.insert(url); | ||
2417 | 334 | query.set_department_id(url.toStdString()); | ||
2418 | 335 | query.set_query_string(url.toStdString()); | ||
2419 | 336 | Department::SPtr dept(Department::create(url.toStdString(), query, name.toStdString())); | ||
2420 | 337 | depts.push_back(dept); | ||
2421 | 338 | } | ||
2422 | 339 | } | ||
2423 | 340 | depts.unique(); | ||
2424 | 341 | if (depts.size() >0) | ||
2425 | 342 | parent->set_subdepartments(depts); | ||
2426 | 343 | } | ||
2427 | 344 | |||
2428 | 345 | void setDepartmentsFromEditorLists(TimeOut timeout, Department::SPtr parent, | ||
2429 | 346 | SearchReplyProxy reply, QString city_url) { | ||
2430 | 347 | Deptset.clear(); | ||
2431 | 348 | DepartmentList depts; | ||
2432 | 349 | qDebug()<<"Retriving departments"; | ||
2433 | 350 | timeout.useAlternateCity(city_url); | ||
2434 | 351 | QJsonArray results = timeout.getEditorLists(1); | ||
2435 | 352 | FOREACH_JSON(json, results) { | ||
2436 | 353 | QJsonObject o = (*json).toObject(); | ||
2437 | 354 | QString uid = o.value("uid").toString(); | ||
2438 | 355 | QString name = o.value("name").toString(); | ||
2439 | 356 | QString url = o.value("url").toString(); | ||
2440 | 357 | QString type = o.value("type").toString(); | ||
2441 | 358 | |||
2442 | 359 | qDebug() << " DeptId is " << url; | ||
2443 | 360 | |||
2444 | 361 | if (name.length() > MAX_DEPT_NAME) { | ||
2445 | 362 | name = name.left(MAX_DEPT_NAME) + "..."; | ||
2446 | 363 | } | ||
2447 | 364 | |||
2448 | 365 | if (type == "curated") { | ||
2449 | 366 | CannedQuery query((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString()); | ||
2450 | 367 | if (Deptset.find(url) != Deptset.end()) { | ||
2451 | 368 | qDebug()<<"duplicated dept " << url; | ||
2452 | 369 | continue; | ||
2453 | 370 | } | ||
2454 | 371 | Deptset.insert(url); | ||
2455 | 372 | query.set_department_id(url.toStdString()); | ||
2456 | 373 | query.set_query_string(url.toStdString()); | ||
2457 | 374 | |||
2458 | 375 | Department::SPtr dept(Department::create(url.toStdString(), query, name.toStdString())); | ||
2459 | 376 | depts.push_back(dept); | ||
2460 | 377 | setSubdepartments(timeout, dept, uid, name, url, reply); | ||
2461 | 378 | } | ||
2462 | 379 | } | ||
2463 | 380 | depts.unique(); | ||
2464 | 381 | parent->set_subdepartments(depts); | ||
2465 | 382 | } | ||
2466 | 383 | |||
2467 | 384 | void TimeoutQuery::getDepartments(SearchReplyProxy const& reply, bool inCity, QString expandUrl) { | ||
2468 | 385 | DepartmentList depts; | ||
2469 | 386 | |||
2470 | 387 | qDebug() << "City found is " << inCity << "url is " <<expandUrl; | ||
2471 | 388 | //clear previous dept sets | ||
2472 | 389 | Deptset.clear(); | ||
2473 | 390 | QString cityUrl = timeout.getCityUrl(); | ||
2474 | 391 | |||
2475 | 392 | Department::SPtr moreCities; | ||
2476 | 393 | Department::SPtr topDept; | ||
2477 | 394 | Department::SPtr expandCity; | ||
2478 | 395 | |||
2479 | 396 | |||
2480 | 397 | CannedQuery topQuery((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString()); | ||
2481 | 398 | topQuery.set_department_id(""); | ||
2482 | 399 | |||
2483 | 400 | //get list of cities | ||
2484 | 401 | std::vector<CityType> list_cities = timeout.getSupportedCities(); | ||
2485 | 402 | |||
2486 | 403 | for (unsigned int i = 0; i < list_cities.size(); i++) { | ||
2487 | 404 | CannedQuery query((SCOPE_PACKAGE+"_"+SCOPE_NAME).toStdString()); | ||
2488 | 405 | query.set_department_id(list_cities[i].name.toStdString()); | ||
2489 | 406 | query.set_query_string(list_cities[i].url.toStdString()); | ||
2490 | 407 | |||
2491 | 408 | Department::SPtr dept(Department::create(("city:" + list_cities[i].url).toStdString(), query, list_cities[i].name.toStdString())); | ||
2492 | 409 | dept->set_has_subdepartments(true); | ||
2493 | 410 | |||
2494 | 411 | //check if it is the dept I need to expand | ||
2495 | 412 | if (expandUrl == list_cities[i].url) | ||
2496 | 413 | expandCity = dept; | ||
2497 | 414 | |||
2498 | 415 | //check if it is the root dept | ||
2499 | 416 | if (!(inCity && cityUrl == list_cities[i].url)) | ||
2500 | 417 | depts.push_back(dept); | ||
2501 | 418 | |||
2502 | 419 | } | ||
2503 | 420 | |||
2504 | 421 | if (inCity){ | ||
2505 | 422 | Department::SPtr rootDept(Department::create("", topQuery, timeout.getCityName().toStdString())); | ||
2506 | 423 | Department::SPtr moreDept(Department::create("moreCities", topQuery, "More Cities")); | ||
2507 | 424 | moreDept->set_subdepartments(depts); | ||
2508 | 425 | setDepartmentsFromEditorLists(timeout, rootDept, reply, cityUrl); | ||
2509 | 426 | rootDept->add_subdepartment(moreDept); | ||
2510 | 427 | topDept = rootDept; | ||
2511 | 428 | |||
2512 | 429 | } else { | ||
2513 | 430 | Department::SPtr rootDept(Department::create("", topQuery, "Pick a city")); | ||
2514 | 431 | rootDept->set_subdepartments(depts); | ||
2515 | 432 | topDept = rootDept; | ||
2516 | 433 | } | ||
2517 | 434 | if(expandUrl != cityUrl) | ||
2518 | 435 | setDepartmentsFromEditorLists(timeout, expandCity, reply, expandUrl); | ||
2519 | 436 | |||
2520 | 437 | reply->register_departments(topDept); | ||
2521 | 438 | } | ||
2522 | 439 | |||
2523 | 440 | void TimeoutQuery::run(SearchReplyProxy const& reply) { | ||
2524 | 441 | |||
2525 | 442 | |||
2526 | 443 | auto mylang = QString::fromStdString(search_metadata().locale()).left(2); | ||
2527 | 444 | qDebug() << "language is " <<mylang; | ||
2528 | 445 | timeout.setLocale(mylang); | ||
2529 | 446 | try { | ||
2530 | 447 | timeout.setLocation(search_metadata().location().latitude(),search_metadata().location().longitude()); | ||
2531 | 448 | } catch (const std::exception &e) { | ||
2532 | 449 | // timeout.setLocation(0,0); | ||
2533 | 450 | } | ||
2534 | 451 | |||
2535 | 452 | CannedQuery query = SearchQueryBase::query(); | ||
2536 | 453 | QString queryString = QString::fromStdString(query.query_string()); | ||
2537 | 454 | QString deptId = QString::fromStdString(query.department_id()); | ||
2538 | 455 | auto city_found = timeout.setupCity(); | ||
2539 | 456 | qDebug() << "city is " << timeout.getCityUrl(); | ||
2540 | 457 | |||
2541 | 458 | if (queryString.length() == 0) { | ||
2542 | 459 | if (deptId == "") { | ||
2543 | 460 | getDepartments(reply, city_found, timeout.getCityUrl()); | ||
2544 | 461 | qDebug() << "Empty search - doing surfacing instead"; | ||
2545 | 462 | if (city_found){ | ||
2546 | 463 | getEditorPicks(timeout, reply); | ||
2547 | 464 | getEditorLists(timeout, reply); | ||
2548 | 465 | } else { | ||
2549 | 466 | getCitySurface(timeout, reply); | ||
2550 | 467 | } | ||
2551 | 468 | return; | ||
2552 | 469 | } | ||
2553 | 470 | if (deptId.contains("city:")) { | ||
2554 | 471 | auto cityUrl = deptId.right(deptId.size()-5); | ||
2555 | 472 | getDepartments(reply, city_found, cityUrl); | ||
2556 | 473 | timeout.useAlternateCity(cityUrl); | ||
2557 | 474 | getEditorPicks(timeout, reply); | ||
2558 | 475 | getEditorLists(timeout, reply); | ||
2559 | 476 | return; | ||
2560 | 477 | } | ||
2561 | 478 | if (deptId.contains("moreCities")) { | ||
2562 | 479 | getDepartments(reply, city_found,timeout.getCityUrl()); | ||
2563 | 480 | return; | ||
2564 | 481 | } | ||
2565 | 482 | auto cityUrl = timeout.getCityFromUrl(deptId); | ||
2566 | 483 | getDepartments(reply, city_found,cityUrl); | ||
2567 | 484 | QString url = deptId; | ||
2568 | 485 | QString title = ""; | ||
2569 | 486 | getGeneric(timeout, url, WIDE_ART, url, title, reply); | ||
2570 | 487 | |||
2571 | 488 | } else { | ||
2572 | 489 | search(timeout, reply); | ||
2573 | 490 | } | ||
2574 | 491 | } | ||
2575 | 0 | 492 | ||
2576 | === added file 'src/TimeOut-query.h' | |||
2577 | --- src/TimeOut-query.h 1970-01-01 00:00:00 +0000 | |||
2578 | +++ src/TimeOut-query.h 2014-09-24 10:37:38 +0000 | |||
2579 | @@ -0,0 +1,69 @@ | |||
2580 | 1 | /* | ||
2581 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2582 | 3 | * Copyright 2014 Canonical Ltd. | ||
2583 | 4 | * | ||
2584 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2585 | 6 | * under the terms of the GNU General Public License as published by | ||
2586 | 7 | * the Free Software Foundation. | ||
2587 | 8 | * | ||
2588 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2589 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2590 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2591 | 12 | * See the GNU General Public License for more details. | ||
2592 | 13 | * | ||
2593 | 14 | * You should have received a copy of the GNU General Public License | ||
2594 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2595 | 16 | */ | ||
2596 | 17 | |||
2597 | 18 | #ifndef TIMEOUT_QUERY_H | ||
2598 | 19 | #define TIMEOUT_QUERY_H | ||
2599 | 20 | |||
2600 | 21 | #include "TimeOut-client.h" | ||
2601 | 22 | |||
2602 | 23 | #include <unity/scopes/SearchQueryBase.h> | ||
2603 | 24 | #include <unity/scopes/ReplyProxyFwd.h> | ||
2604 | 25 | #include <unity/scopes/CategorisedResult.h> | ||
2605 | 26 | |||
2606 | 27 | #include <QFile> | ||
2607 | 28 | #include <QString> | ||
2608 | 29 | #include <QMap> | ||
2609 | 30 | #include <set> | ||
2610 | 31 | #include <unity/scopes/Location.h> | ||
2611 | 32 | #include <unity/scopes/Location.h> | ||
2612 | 33 | #include <unity/scopes/SearchMetadata.h> | ||
2613 | 34 | #include <QTextDocument> | ||
2614 | 35 | #include <QCoreApplication> | ||
2615 | 36 | |||
2616 | 37 | |||
2617 | 38 | using namespace unity::scopes; | ||
2618 | 39 | |||
2619 | 40 | class TimeOut; | ||
2620 | 41 | |||
2621 | 42 | class TimeoutQuery : public SearchQueryBase | ||
2622 | 43 | { | ||
2623 | 44 | public: | ||
2624 | 45 | TimeoutQuery(CannedQuery const&, SearchMetadata const&, TimeOut &, QString); | ||
2625 | 46 | ~TimeoutQuery(); | ||
2626 | 47 | virtual void cancelled() override; | ||
2627 | 48 | |||
2628 | 49 | virtual void run(SearchReplyProxy const& reply) override; | ||
2629 | 50 | |||
2630 | 51 | void getDepartments(SearchReplyProxy const& reply, bool inCity, QString expandUrl); | ||
2631 | 52 | void search(TimeOut const& timeout, SearchReplyProxy const& reply); | ||
2632 | 53 | void getEditorLists(TimeOut const& timeout, SearchReplyProxy const& reply); | ||
2633 | 54 | void getEditorPicks(TimeOut const& timeout, SearchReplyProxy const& reply); | ||
2634 | 55 | void getGeneric(TimeOut const& timeout, QString &url, std::string &categoryJson, | ||
2635 | 56 | QString &id, QString &title, SearchReplyProxy const& reply); | ||
2636 | 57 | void getCitySurface(TimeOut timeout, SearchReplyProxy reply); | ||
2637 | 58 | |||
2638 | 59 | |||
2639 | 60 | |||
2640 | 61 | private: | ||
2641 | 62 | std::string getRenderer(QString name); | ||
2642 | 63 | TimeOut timeout; | ||
2643 | 64 | //avoid registering multiple depts | ||
2644 | 65 | std::set<QString> Deptset; | ||
2645 | 66 | QString scopePath_; | ||
2646 | 67 | }; | ||
2647 | 68 | |||
2648 | 69 | #endif | ||
2649 | 0 | 70 | ||
2650 | === added file 'src/TimeOut-scope.cpp' | |||
2651 | --- src/TimeOut-scope.cpp 1970-01-01 00:00:00 +0000 | |||
2652 | +++ src/TimeOut-scope.cpp 2014-09-24 10:37:38 +0000 | |||
2653 | @@ -0,0 +1,62 @@ | |||
2654 | 1 | /* | ||
2655 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2656 | 3 | * Copyright 2014 Canonical Ltd. | ||
2657 | 4 | * | ||
2658 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2659 | 6 | * under the terms of the GNU General Public License as published by | ||
2660 | 7 | * the Free Software Foundation. | ||
2661 | 8 | * | ||
2662 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2663 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2664 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2665 | 12 | * See the GNU General Public License for more details. | ||
2666 | 13 | * | ||
2667 | 14 | * You should have received a copy of the GNU General Public License | ||
2668 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2669 | 16 | */ | ||
2670 | 17 | |||
2671 | 18 | #include "TimeOut-scope.h" | ||
2672 | 19 | #include "TimeOut-query.h" | ||
2673 | 20 | #include "TimeOut-preview.h" | ||
2674 | 21 | #include <unity-scopes.h> | ||
2675 | 22 | |||
2676 | 23 | using namespace unity::scopes; | ||
2677 | 24 | |||
2678 | 25 | void TimeoutScope::start(std::string const&) { | ||
2679 | 26 | timeout.setCacheDirectory(cache_directory()); | ||
2680 | 27 | } | ||
2681 | 28 | |||
2682 | 29 | void TimeoutScope::stop() { | ||
2683 | 30 | } | ||
2684 | 31 | |||
2685 | 32 | SearchQueryBase::UPtr TimeoutScope::search(CannedQuery const &q, SearchMetadata const& metadata) { | ||
2686 | 33 | const QString scopePath = QString::fromStdString(scope_directory()); | ||
2687 | 34 | SearchQueryBase::UPtr query(new TimeoutQuery(q, metadata, timeout, scopePath)); | ||
2688 | 35 | return query; | ||
2689 | 36 | } | ||
2690 | 37 | |||
2691 | 38 | PreviewQueryBase::UPtr TimeoutScope::preview(Result const& result, ActionMetadata const& metadata) { | ||
2692 | 39 | PreviewQueryBase::UPtr preview(new TimeoutPreview(result, metadata, timeout)); | ||
2693 | 40 | return preview; | ||
2694 | 41 | } | ||
2695 | 42 | |||
2696 | 43 | #define EXPORT __attribute__ ((visibility ("default"))) | ||
2697 | 44 | |||
2698 | 45 | extern "C" | ||
2699 | 46 | { | ||
2700 | 47 | |||
2701 | 48 | EXPORT | ||
2702 | 49 | ScopeBase* | ||
2703 | 50 | // cppcheck-suppress unusedFunction | ||
2704 | 51 | UNITY_SCOPE_CREATE_FUNCTION() { | ||
2705 | 52 | return new TimeoutScope(); | ||
2706 | 53 | } | ||
2707 | 54 | |||
2708 | 55 | EXPORT | ||
2709 | 56 | void | ||
2710 | 57 | // cppcheck-suppress unusedFunction | ||
2711 | 58 | UNITY_SCOPE_DESTROY_FUNCTION(ScopeBase* scope_base) { | ||
2712 | 59 | delete scope_base; | ||
2713 | 60 | } | ||
2714 | 61 | |||
2715 | 62 | } | ||
2716 | 0 | 63 | ||
2717 | === added file 'src/TimeOut-scope.h' | |||
2718 | --- src/TimeOut-scope.h 1970-01-01 00:00:00 +0000 | |||
2719 | +++ src/TimeOut-scope.h 2014-09-24 10:37:38 +0000 | |||
2720 | @@ -0,0 +1,51 @@ | |||
2721 | 1 | /* | ||
2722 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2723 | 3 | * Copyright 2014 Canonical Ltd. | ||
2724 | 4 | * | ||
2725 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2726 | 6 | * under the terms of the GNU General Public License as published by | ||
2727 | 7 | * the Free Software Foundation. | ||
2728 | 8 | * | ||
2729 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2730 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2731 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2732 | 12 | * See the GNU General Public License for more details. | ||
2733 | 13 | * | ||
2734 | 14 | * You should have received a copy of the GNU General Public License | ||
2735 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2736 | 16 | */ | ||
2737 | 17 | |||
2738 | 18 | #ifndef DEMOSCOPE_H | ||
2739 | 19 | #define DEMOSCOPE_H | ||
2740 | 20 | |||
2741 | 21 | #include "TimeOut-client.h" | ||
2742 | 22 | |||
2743 | 23 | #include <unity/scopes/ScopeBase.h> | ||
2744 | 24 | #include <unity/scopes/QueryBase.h> | ||
2745 | 25 | #include <unity/scopes/ReplyProxyFwd.h> | ||
2746 | 26 | #include <unity/scopes/QueryBase.h> | ||
2747 | 27 | #include <unity/scopes/PreviewQueryBase.h> | ||
2748 | 28 | #include <unity/scopes/Location.h> | ||
2749 | 29 | #include <QCoreApplication> | ||
2750 | 30 | |||
2751 | 31 | |||
2752 | 32 | |||
2753 | 33 | using namespace unity::scopes; | ||
2754 | 34 | |||
2755 | 35 | class TimeoutScope : public unity::scopes::ScopeBase | ||
2756 | 36 | { | ||
2757 | 37 | public: | ||
2758 | 38 | virtual void start(std::string const&) override; | ||
2759 | 39 | |||
2760 | 40 | virtual void stop() override; | ||
2761 | 41 | |||
2762 | 42 | PreviewQueryBase::UPtr preview(const Result&, const ActionMetadata&) override; | ||
2763 | 43 | |||
2764 | 44 | virtual SearchQueryBase::UPtr search(CannedQuery const& q, SearchMetadata const&) override; | ||
2765 | 45 | |||
2766 | 46 | private: | ||
2767 | 47 | TimeOut timeout; | ||
2768 | 48 | |||
2769 | 49 | }; | ||
2770 | 50 | |||
2771 | 51 | #endif | ||
2772 | 0 | 52 | ||
2773 | === added file 'src/TimeOut-scope.h.autosave' | |||
2774 | --- src/TimeOut-scope.h.autosave 1970-01-01 00:00:00 +0000 | |||
2775 | +++ src/TimeOut-scope.h.autosave 2014-09-24 10:37:38 +0000 | |||
2776 | @@ -0,0 +1,50 @@ | |||
2777 | 1 | /* | ||
2778 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2779 | 3 | * Copyright 2014 Canonical Ltd. | ||
2780 | 4 | * | ||
2781 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2782 | 6 | * under the terms of the GNU General Public License as published by | ||
2783 | 7 | * the Free Software Foundation. | ||
2784 | 8 | * | ||
2785 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2786 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2787 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2788 | 12 | * See the GNU General Public License for more details. | ||
2789 | 13 | * | ||
2790 | 14 | * You should have received a copy of the GNU General Public License | ||
2791 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2792 | 16 | */ | ||
2793 | 17 | |||
2794 | 18 | #ifndef DEMOSCOPE_H | ||
2795 | 19 | #define DEMOSCOPE_H | ||
2796 | 20 | |||
2797 | 21 | #include "TimeOut-client.h" | ||
2798 | 22 | |||
2799 | 23 | #include <unity/scopes/ScopeBase.h> | ||
2800 | 24 | #include <unity/scopes/QueryBase.h> | ||
2801 | 25 | #include <unity/scopes/ReplyProxyFwd.h> | ||
2802 | 26 | #include <unity/scopes/QueryBase.h> | ||
2803 | 27 | #include <unity/scopes/PreviewQueryBase.h> | ||
2804 | 28 | #include <unity/scopes/Location.h> | ||
2805 | 29 | |||
2806 | 30 | |||
2807 | 31 | |||
2808 | 32 | using namespace unity::scopes; | ||
2809 | 33 | |||
2810 | 34 | class TimeoutScope : public unity::scopes::ScopeBase | ||
2811 | 35 | { | ||
2812 | 36 | public: | ||
2813 | 37 | virtual void start(std::string const&) override; | ||
2814 | 38 | |||
2815 | 39 | virtual void stop() override; | ||
2816 | 40 | |||
2817 | 41 | PreviewQueryBase::UPtr preview(const Result&, const ActionMetadata&) override; | ||
2818 | 42 | |||
2819 | 43 | virtual SearchQueryBase::UPtr search(CannedQuery const& q, SearchMetadata const&) override; | ||
2820 | 44 | |||
2821 | 45 | private: | ||
2822 | 46 | TimeOut timeout; | ||
2823 | 47 | |||
2824 | 48 | }; | ||
2825 | 49 | |||
2826 | 50 | #endif | ||
2827 | 0 | 51 | ||
2828 | === added file 'src/com.canonical.scopes.timeout_timeout.ini' | |||
2829 | --- src/com.canonical.scopes.timeout_timeout.ini 1970-01-01 00:00:00 +0000 | |||
2830 | +++ src/com.canonical.scopes.timeout_timeout.ini 2014-09-24 10:37:38 +0000 | |||
2831 | @@ -0,0 +1,13 @@ | |||
2832 | 1 | [ScopeConfig] | ||
2833 | 2 | DisplayName = TimeOut | ||
2834 | 3 | Description = This is an Ubuntu search plugin that enables information from TimeOut to be searched and displayed in the Dash. If you do not wish to search this content source, you can disable this search plugin. | ||
2835 | 4 | Icon = icon.png | ||
2836 | 5 | Author = Canonical Ltd. | ||
2837 | 6 | SearchHint = Search TimeOut | ||
2838 | 7 | LocationDataNeeded=true | ||
2839 | 8 | [Appearance] | ||
2840 | 9 | Background = color:///#000000 | ||
2841 | 10 | PageHeader.Logo = logo.png | ||
2842 | 11 | PageHeader.Background = color:///#000000 | ||
2843 | 12 | PageHeader.ForegroundColor = #FFFFFF | ||
2844 | 13 | BackgroundColor = #FFFFFF | ||
2845 | 0 | 14 | ||
2846 | === added file 'src/com.canonical.scopes.timeout_timeout_automoc.cpp' | |||
2847 | --- src/com.canonical.scopes.timeout_timeout_automoc.cpp 1970-01-01 00:00:00 +0000 | |||
2848 | +++ src/com.canonical.scopes.timeout_timeout_automoc.cpp 2014-09-24 10:37:38 +0000 | |||
2849 | @@ -0,0 +1,2 @@ | |||
2850 | 1 | /* This file is autogenerated, do not edit*/ | ||
2851 | 2 | enum some_compilers { need_more_than_nothing }; | ||
2852 | 0 | 3 | ||
2853 | === added file 'src/config.h.in' | |||
2854 | --- src/config.h.in 1970-01-01 00:00:00 +0000 | |||
2855 | +++ src/config.h.in 2014-09-24 10:37:38 +0000 | |||
2856 | @@ -0,0 +1,47 @@ | |||
2857 | 1 | /* | ||
2858 | 2 | * This file is part of Ubuntu TimeOut Scope. | ||
2859 | 3 | * Copyright 2014 Canonical Ltd. | ||
2860 | 4 | * | ||
2861 | 5 | * TimeOut Scope is free software: you can redistribute it and/or modify it | ||
2862 | 6 | * under the terms of the GNU General Public License as published by | ||
2863 | 7 | * the Free Software Foundation. | ||
2864 | 8 | * | ||
2865 | 9 | * TimeOut Scope is distributed in the hope that it will be useful, | ||
2866 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2867 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
2868 | 12 | * See the GNU General Public License for more details. | ||
2869 | 13 | * | ||
2870 | 14 | * You should have received a copy of the GNU General Public License | ||
2871 | 15 | * along with TimeOut Scope. If not, see <http://www.gnu.org/licenses/>. | ||
2872 | 16 | */ | ||
2873 | 17 | |||
2874 | 18 | #ifndef CONFIG_H | ||
2875 | 19 | #define CONFIG_H | ||
2876 | 20 | |||
2877 | 21 | #include <QString> | ||
2878 | 22 | |||
2879 | 23 | /*** Please edit this section. ***/ | ||
2880 | 24 | const QString HOME_URL = "http://timeout.com/"; | ||
2881 | 25 | const QString MOBILE_URL = "http://m.timeout.com/"; | ||
2882 | 26 | const QString SURFACING_LAYOUT = "wide-art"; | ||
2883 | 27 | const QString READ_MORE = "Read more..."; | ||
2884 | 28 | const QString NO_CONNECTION = "No connection."; | ||
2885 | 29 | const QString RESULTS = "Results:"; | ||
2886 | 30 | const QString ERROR = "Error"; | ||
2887 | 31 | |||
2888 | 32 | // If false, your first department will become your top (root) department. | ||
2889 | 33 | //const bool BROWSE_AT_ROOT = true; | ||
2890 | 34 | //const QString BROWSE = "Browse"; | ||
2891 | 35 | |||
2892 | 36 | /*** DO NOT edit this section! ***/ | ||
2893 | 37 | const QString SCOPE_TITLE = "@SCOPE_TITLE@"; | ||
2894 | 38 | const QString SCOPE_PACKAGE = "@SCOPE_PACKAGE@"; | ||
2895 | 39 | const QString SCOPE_NAME = "@SCOPE_NAME@"; | ||
2896 | 40 | |||
2897 | 41 | //WORK AROUND MADRID IUDs | ||
2898 | 42 | const QString MAD_SHOPPING = "tiendas"; | ||
2899 | 43 | const QString MAD_BAR = "bares"; | ||
2900 | 44 | const QString MAD_TTODO = "qu_hacer"; | ||
2901 | 45 | const QString MAD_RESTAURANTS = "restaurantes"; | ||
2902 | 46 | |||
2903 | 47 | #endif | ||
2904 | 0 | 48 | ||
2905 | === added file 'src/timeout.ini' | |||
2906 | --- src/timeout.ini 1970-01-01 00:00:00 +0000 | |||
2907 | +++ src/timeout.ini 2014-09-24 10:37:38 +0000 | |||
2908 | @@ -0,0 +1,13 @@ | |||
2909 | 1 | [ScopeConfig] | ||
2910 | 2 | DisplayName = TimeOut | ||
2911 | 3 | Description = This is an Ubuntu search plugin that enables information from TimeOut to be searched and displayed in the Dash. If you do not wish to search this content source, you can disable this search plugin. | ||
2912 | 4 | Icon = icon.png | ||
2913 | 5 | Author = Canonical Ltd. | ||
2914 | 6 | SearchHint = Search TimeOut | ||
2915 | 7 | LocationDataNeeded=true | ||
2916 | 8 | [Appearance] | ||
2917 | 9 | Background = color:///#000000 | ||
2918 | 10 | PageHeader.Logo = /opt/click.ubuntu.com/com.canonical.scopes.timeout/current/images/logo.png | ||
2919 | 11 | PageHeader.Background = color:///#000000 | ||
2920 | 12 | PageHeader.ForegroundColor = #FFFFFF | ||
2921 | 13 | BackgroundColor = #FFFFFF | ||
2922 | 0 | 14 | ||
2923 | === added file 'src/timeout_automoc.cpp' | |||
2924 | --- src/timeout_automoc.cpp 1970-01-01 00:00:00 +0000 | |||
2925 | +++ src/timeout_automoc.cpp 2014-09-24 10:37:38 +0000 | |||
2926 | @@ -0,0 +1,2 @@ | |||
2927 | 1 | /* This file is autogenerated, do not edit*/ | ||
2928 | 2 | enum some_compilers { need_more_than_nothing }; | ||
2929 | 0 | 3 | ||
2930 | === added directory 'test' | |||
2931 | === added file 'test/CMakeLists.txt' | |||
2932 | --- test/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2933 | +++ test/CMakeLists.txt 2014-09-24 10:37:38 +0000 | |||
2934 | @@ -0,0 +1,24 @@ | |||
2935 | 1 | if (NOT DEFINED GMOCK_ROOT) | ||
2936 | 2 | set(GMOCK_ROOT /usr/src/gmock) | ||
2937 | 3 | endif() | ||
2938 | 4 | add_subdirectory(${GMOCK_ROOT} gmock) | ||
2939 | 5 | include_directories(${GMOCK_ROOT}/gtest/include) | ||
2940 | 6 | |||
2941 | 7 | set(gtest_libs gtest gmock gmock_main) | ||
2942 | 8 | foreach(target ${gtest_libs}) | ||
2943 | 9 | set_property(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-missing-field-initializers -Wno-missing-declarations") | ||
2944 | 10 | endforeach() | ||
2945 | 11 | |||
2946 | 12 | add_subdirectory(files) | ||
2947 | 13 | |||
2948 | 14 | include_directories(${UNITY_INCLUDE_DIRS}) | ||
2949 | 15 | find_package(Qt5Network REQUIRED) | ||
2950 | 16 | |||
2951 | 17 | add_executable(test-timeout-client | ||
2952 | 18 | test-timeout-client.cpp | ||
2953 | 19 | ../src/TimeOut-client.cpp | ||
2954 | 20 | ) | ||
2955 | 21 | |||
2956 | 22 | qt5_use_modules(test-timeout-client Network) | ||
2957 | 23 | target_link_libraries(test-timeout-client ${UNITY_LDFLAGS} ${gtest_libs}) | ||
2958 | 24 | add_test(test-timeout-client test-timeout-client) | ||
2959 | 0 | 25 | ||
2960 | === added directory 'test/files' | |||
2961 | === added file 'test/files/CMakeLists.txt' | |||
2962 | --- test/files/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2963 | +++ test/files/CMakeLists.txt 2014-09-24 10:37:38 +0000 | |||
2964 | @@ -0,0 +1,1 @@ | |||
2965 | 1 | configure_file(response-mobile.json ${CMAKE_CURRENT_BINARY_DIR}/response-mobile.json COPYONLY) | ||
2966 | 0 | 2 | ||
2967 | === added file 'test/files/response-mobile.json' | |||
2968 | === added file 'test/test-timeout-client.cpp' | |||
2969 | --- test/test-timeout-client.cpp 1970-01-01 00:00:00 +0000 | |||
2970 | +++ test/test-timeout-client.cpp 2014-09-24 10:37:38 +0000 | |||
2971 | @@ -0,0 +1,16 @@ | |||
2972 | 1 | #include <gmock/gmock.h> | ||
2973 | 2 | #include <gtest/gtest.h> | ||
2974 | 3 | |||
2975 | 4 | #include <QFile> | ||
2976 | 5 | |||
2977 | 6 | #include "../src/TimeOut-client.h" | ||
2978 | 7 | |||
2979 | 8 | using ::testing::_; | ||
2980 | 9 | |||
2981 | 10 | TEST(TimeOut, getCities) { | ||
2982 | 11 | } | ||
2983 | 12 | |||
2984 | 13 | int main(int argc, char **argv) { | ||
2985 | 14 | ::testing::InitGoogleTest(&argc, argv); | ||
2986 | 15 | return RUN_ALL_TESTS(); | ||
2987 | 16 | } | ||
2988 | 0 | 17 | ||
2989 | === added file 'timeout-scope.json' | |||
2990 | --- timeout-scope.json 1970-01-01 00:00:00 +0000 | |||
2991 | +++ timeout-scope.json 2014-09-24 10:37:38 +0000 | |||
2992 | @@ -0,0 +1,6 @@ | |||
2993 | 1 | { | ||
2994 | 2 | "policy_groups": [ | ||
2995 | 3 | "networking" | ||
2996 | 4 | ], | ||
2997 | 5 | "policy_version": 1.1 | ||
2998 | 6 | } | ||
2999 | 0 | \ No newline at end of file | 7 | \ No newline at end of file |
3000 | 1 | 8 | ||
3001 | === added file 'timeout.cbp' | |||
3002 | --- timeout.cbp 1970-01-01 00:00:00 +0000 | |||
3003 | +++ timeout.cbp 2014-09-24 10:37:38 +0000 | |||
3004 | @@ -0,0 +1,199 @@ | |||
3005 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
3006 | 2 | <CodeBlocks_project_file> | ||
3007 | 3 | <FileVersion major="1" minor="6" /> | ||
3008 | 4 | <Project> | ||
3009 | 5 | <Option title="timeout" /> | ||
3010 | 6 | <Option makefile_is_custom="1" /> | ||
3011 | 7 | <Option compiler="gcc" /> | ||
3012 | 8 | <Option virtualFolders="CMake Files\;CMake Files\src\;CMake Files\..\;CMake Files\..\..\;CMake Files\..\..\..\;CMake Files\..\..\..\..\;CMake Files\..\..\..\..\usr\;CMake Files\..\..\..\..\usr\lib\;CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\;CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\;CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Network\;CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Core\;CMake Files\data\;" /> | ||
3013 | 9 | <Build> | ||
3014 | 10 | <Target title="all"> | ||
3015 | 11 | <Option working_dir="/home/victorp/qtworkspace/timeout" /> | ||
3016 | 12 | <Option type="4" /> | ||
3017 | 13 | <MakeCommands> | ||
3018 | 14 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 all" /> | ||
3019 | 15 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 "$file"" /> | ||
3020 | 16 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3021 | 17 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3022 | 18 | </MakeCommands> | ||
3023 | 19 | </Target> | ||
3024 | 20 | <Target title="install"> | ||
3025 | 21 | <Option working_dir="/home/victorp/qtworkspace/timeout" /> | ||
3026 | 22 | <Option type="4" /> | ||
3027 | 23 | <MakeCommands> | ||
3028 | 24 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 install" /> | ||
3029 | 25 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 "$file"" /> | ||
3030 | 26 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3031 | 27 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3032 | 28 | </MakeCommands> | ||
3033 | 29 | </Target> | ||
3034 | 30 | <Target title="install/local"> | ||
3035 | 31 | <Option working_dir="/home/victorp/qtworkspace/timeout" /> | ||
3036 | 32 | <Option type="4" /> | ||
3037 | 33 | <MakeCommands> | ||
3038 | 34 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 install/local" /> | ||
3039 | 35 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 "$file"" /> | ||
3040 | 36 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3041 | 37 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3042 | 38 | </MakeCommands> | ||
3043 | 39 | </Target> | ||
3044 | 40 | <Target title="install/strip"> | ||
3045 | 41 | <Option working_dir="/home/victorp/qtworkspace/timeout" /> | ||
3046 | 42 | <Option type="4" /> | ||
3047 | 43 | <MakeCommands> | ||
3048 | 44 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 install/strip" /> | ||
3049 | 45 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 "$file"" /> | ||
3050 | 46 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3051 | 47 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3052 | 48 | </MakeCommands> | ||
3053 | 49 | </Target> | ||
3054 | 50 | <Target title="list_install_components"> | ||
3055 | 51 | <Option working_dir="/home/victorp/qtworkspace/timeout" /> | ||
3056 | 52 | <Option type="4" /> | ||
3057 | 53 | <MakeCommands> | ||
3058 | 54 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 list_install_components" /> | ||
3059 | 55 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 "$file"" /> | ||
3060 | 56 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3061 | 57 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3062 | 58 | </MakeCommands> | ||
3063 | 59 | </Target> | ||
3064 | 60 | <Target title="rebuild_cache"> | ||
3065 | 61 | <Option working_dir="/home/victorp/qtworkspace/timeout" /> | ||
3066 | 62 | <Option type="4" /> | ||
3067 | 63 | <MakeCommands> | ||
3068 | 64 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 rebuild_cache" /> | ||
3069 | 65 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 "$file"" /> | ||
3070 | 66 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3071 | 67 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/Makefile" VERBOSE=1 clean" /> | ||
3072 | 68 | </MakeCommands> | ||
3073 | 69 | </Target> | ||
3074 | 70 | <Target title="timeout"> | ||
3075 | 71 | <Option output="/home/victorp/qtworkspace/timeout/src/libtimeout.so" prefix_auto="0" extension_auto="0" /> | ||
3076 | 72 | <Option working_dir="/home/victorp/qtworkspace/timeout/src" /> | ||
3077 | 73 | <Option object_output="./" /> | ||
3078 | 74 | <Option type="3" /> | ||
3079 | 75 | <Option compiler="gcc" /> | ||
3080 | 76 | <Compiler> | ||
3081 | 77 | <Add option="-DQT_NETWORK_LIB" /> | ||
3082 | 78 | <Add option="-DQT_CORE_LIB" /> | ||
3083 | 79 | <Add option="-DQT_NO_KEYWORDS" /> | ||
3084 | 80 | <Add option="-DQT_NO_DEBUG" /> | ||
3085 | 81 | <Add directory="/usr/arm-linux-gnueabihf/include/c++/4.8.2" /> | ||
3086 | 82 | <Add directory="/usr/arm-linux-gnueabihf/include/c++/4.8.2/arm-linux-gnueabihf" /> | ||
3087 | 83 | <Add directory="/usr/arm-linux-gnueabihf/include/c++/4.8.2/backward" /> | ||
3088 | 84 | <Add directory="/usr/include" /> | ||
3089 | 85 | <Add directory="/usr/include/arm-linux-gnueabihf" /> | ||
3090 | 86 | <Add directory="/usr/include/arm-linux-gnueabihf/qt5" /> | ||
3091 | 87 | <Add directory="/usr/include/arm-linux-gnueabihf/qt5/QtCore" /> | ||
3092 | 88 | <Add directory="/usr/include/arm-linux-gnueabihf/qt5/QtNetwork" /> | ||
3093 | 89 | <Add directory="/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++" /> | ||
3094 | 90 | <Add directory="/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/include" /> | ||
3095 | 91 | <Add directory="/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include" /> | ||
3096 | 92 | <Add directory="/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include-fixed" /> | ||
3097 | 93 | </Compiler> | ||
3098 | 94 | <MakeCommands> | ||
3099 | 95 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 timeout" /> | ||
3100 | 96 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 "$file"" /> | ||
3101 | 97 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 clean" /> | ||
3102 | 98 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 clean" /> | ||
3103 | 99 | </MakeCommands> | ||
3104 | 100 | </Target> | ||
3105 | 101 | <Target title="timeout/fast"> | ||
3106 | 102 | <Option output="/home/victorp/qtworkspace/timeout/src/libtimeout.so" prefix_auto="0" extension_auto="0" /> | ||
3107 | 103 | <Option working_dir="/home/victorp/qtworkspace/timeout/src" /> | ||
3108 | 104 | <Option object_output="./" /> | ||
3109 | 105 | <Option type="3" /> | ||
3110 | 106 | <Option compiler="gcc" /> | ||
3111 | 107 | <Compiler> | ||
3112 | 108 | <Add option="-DQT_NETWORK_LIB" /> | ||
3113 | 109 | <Add option="-DQT_CORE_LIB" /> | ||
3114 | 110 | <Add option="-DQT_NO_KEYWORDS" /> | ||
3115 | 111 | <Add option="-DQT_NO_DEBUG" /> | ||
3116 | 112 | <Add directory="/usr/arm-linux-gnueabihf/include/c++/4.8.2" /> | ||
3117 | 113 | <Add directory="/usr/arm-linux-gnueabihf/include/c++/4.8.2/arm-linux-gnueabihf" /> | ||
3118 | 114 | <Add directory="/usr/arm-linux-gnueabihf/include/c++/4.8.2/backward" /> | ||
3119 | 115 | <Add directory="/usr/include" /> | ||
3120 | 116 | <Add directory="/usr/include/arm-linux-gnueabihf" /> | ||
3121 | 117 | <Add directory="/usr/include/arm-linux-gnueabihf/qt5" /> | ||
3122 | 118 | <Add directory="/usr/include/arm-linux-gnueabihf/qt5/QtCore" /> | ||
3123 | 119 | <Add directory="/usr/include/arm-linux-gnueabihf/qt5/QtNetwork" /> | ||
3124 | 120 | <Add directory="/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++" /> | ||
3125 | 121 | <Add directory="/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/include" /> | ||
3126 | 122 | <Add directory="/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include" /> | ||
3127 | 123 | <Add directory="/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include-fixed" /> | ||
3128 | 124 | </Compiler> | ||
3129 | 125 | <MakeCommands> | ||
3130 | 126 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 timeout/fast" /> | ||
3131 | 127 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 "$file"" /> | ||
3132 | 128 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 clean" /> | ||
3133 | 129 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 clean" /> | ||
3134 | 130 | </MakeCommands> | ||
3135 | 131 | </Target> | ||
3136 | 132 | <Target title="timeout_automoc"> | ||
3137 | 133 | <Option working_dir="/home/victorp/qtworkspace/timeout/src" /> | ||
3138 | 134 | <Option type="4" /> | ||
3139 | 135 | <MakeCommands> | ||
3140 | 136 | <Build command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 timeout_automoc" /> | ||
3141 | 137 | <CompileFile command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 "$file"" /> | ||
3142 | 138 | <Clean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 clean" /> | ||
3143 | 139 | <DistClean command="/usr/bin/make -f "/home/victorp/qtworkspace/timeout/src/Makefile" VERBOSE=1 clean" /> | ||
3144 | 140 | </MakeCommands> | ||
3145 | 141 | </Target> | ||
3146 | 142 | </Build> | ||
3147 | 143 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-client.cpp"> | ||
3148 | 144 | </Unit> | ||
3149 | 145 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-preview.cpp"> | ||
3150 | 146 | </Unit> | ||
3151 | 147 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-query.cpp"> | ||
3152 | 148 | </Unit> | ||
3153 | 149 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-scope.cpp"> | ||
3154 | 150 | </Unit> | ||
3155 | 151 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-client.h"> | ||
3156 | 152 | </Unit> | ||
3157 | 153 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-preview.h"> | ||
3158 | 154 | </Unit> | ||
3159 | 155 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-query.h"> | ||
3160 | 156 | </Unit> | ||
3161 | 157 | <Unit filename="/home/victorp/qtworkspace/timeout/src/TimeOut-scope.h"> | ||
3162 | 158 | </Unit> | ||
3163 | 159 | <Unit filename="/home/victorp/qtworkspace/timeout/CMakeLists.txt"> | ||
3164 | 160 | <Option virtualFolder="CMake Files\" /> | ||
3165 | 161 | </Unit> | ||
3166 | 162 | <Unit filename="/home/victorp/qtworkspace/timeout/manifest.json.in"> | ||
3167 | 163 | <Option virtualFolder="CMake Files\" /> | ||
3168 | 164 | </Unit> | ||
3169 | 165 | <Unit filename="/home/victorp/qtworkspace/timeout/src/CMakeLists.txt"> | ||
3170 | 166 | <Option virtualFolder="CMake Files\src\" /> | ||
3171 | 167 | </Unit> | ||
3172 | 168 | <Unit filename="/home/victorp/qtworkspace/timeout/src/config.h.in"> | ||
3173 | 169 | <Option virtualFolder="CMake Files\src\" /> | ||
3174 | 170 | </Unit> | ||
3175 | 171 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Network/Qt5NetworkConfigVersion.cmake"> | ||
3176 | 172 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Network\" /> | ||
3177 | 173 | </Unit> | ||
3178 | 174 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Network/Qt5NetworkConfig.cmake"> | ||
3179 | 175 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Network\" /> | ||
3180 | 176 | </Unit> | ||
3181 | 177 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Core/Qt5CoreConfigVersion.cmake"> | ||
3182 | 178 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Core\" /> | ||
3183 | 179 | </Unit> | ||
3184 | 180 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Core/Qt5CoreConfig.cmake"> | ||
3185 | 181 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Core\" /> | ||
3186 | 182 | </Unit> | ||
3187 | 183 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Core/Qt5CoreConfigExtras.cmake"> | ||
3188 | 184 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Core\" /> | ||
3189 | 185 | </Unit> | ||
3190 | 186 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake"> | ||
3191 | 187 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Core\" /> | ||
3192 | 188 | </Unit> | ||
3193 | 189 | <Unit filename="/home/victorp/qtworkspace/timeout/../../../../usr/lib/arm-linux-gnueabihf/cmake/Qt5Core/Qt5CoreMacros.cmake"> | ||
3194 | 190 | <Option virtualFolder="CMake Files\..\..\..\..\usr\lib\arm-linux-gnueabihf\cmake\Qt5Core\" /> | ||
3195 | 191 | </Unit> | ||
3196 | 192 | <Unit filename="/home/victorp/qtworkspace/timeout/data/CMakeLists.txt"> | ||
3197 | 193 | <Option virtualFolder="CMake Files\data\" /> | ||
3198 | 194 | </Unit> | ||
3199 | 195 | <Unit filename="/home/victorp/qtworkspace/timeout/data/timeout.ini.in"> | ||
3200 | 196 | <Option virtualFolder="CMake Files\data\" /> | ||
3201 | 197 | </Unit> | ||
3202 | 198 | </Project> | ||
3203 | 199 | </CodeBlocks_project_file> | ||
3204 | 0 | 200 | ||
3205 | === added file 'timeout.json' | |||
3206 | --- timeout.json 1970-01-01 00:00:00 +0000 | |||
3207 | +++ timeout.json 2014-09-24 10:37:38 +0000 | |||
3208 | @@ -0,0 +1,6 @@ | |||
3209 | 1 | { | ||
3210 | 2 | "policy_groups": [ | ||
3211 | 3 | "networking" | ||
3212 | 4 | ], | ||
3213 | 5 | "policy_version": 1.1 | ||
3214 | 6 | } | ||
3215 | 0 | \ No newline at end of file | 7 | \ No newline at end of file |