Merge lp:~seb128/indicator-appmenu/clean-hud-leftover into lp:indicator-appmenu/14.04
- clean-hud-leftover
- Merge into trunk.14.04
Proposed by
Sebastien Bacher
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ted Gould | ||||
Approved revision: | 259 | ||||
Merged at revision: | 259 | ||||
Proposed branch: | lp:~seb128/indicator-appmenu/clean-hud-leftover | ||||
Merge into: | lp:indicator-appmenu/14.04 | ||||
Diff against target: |
749 lines (+6/-694) 5 files modified
debian/control (+0/-1) po/POTFILES.skip (+0/-2) po/indicator-appmenu.pot (+6/-122) src/usage-tracker.c (+0/-510) src/usage-tracker.h (+0/-59) |
||||
To merge this branch: | bzr merge lp:~seb128/indicator-appmenu/clean-hud-leftover | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Indicator Applet Developers | Pending | ||
Review via email: mp+212127@code.launchpad.net |
Commit message
Clean leftover hud files, it has its own source now. Drop depends as well
Description of the change
Clean leftover hud files, it has its own source now. Drop depends as well
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Ted Gould (ted) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' |
2 | --- debian/control 2013-07-22 04:46:18 +0000 |
3 | +++ debian/control 2014-03-21 10:25:21 +0000 |
4 | @@ -30,7 +30,6 @@ |
5 | Architecture: any |
6 | Depends: ${shlibs:Depends}, |
7 | ${misc:Depends}, |
8 | - hud, |
9 | Recommends: indicator-applet | indicator-renderer, |
10 | unity-gtk2-module, |
11 | unity-gtk3-module, |
12 | |
13 | === modified file 'po/POTFILES.skip' |
14 | --- po/POTFILES.skip 2012-03-21 17:31:16 +0000 |
15 | +++ po/POTFILES.skip 2014-03-21 10:25:21 +0000 |
16 | @@ -1,6 +1,4 @@ |
17 | src/create-db.c |
18 | src/gen-application-menu-registrar.xml.c |
19 | src/gen-application-menu-renderer.xml.c |
20 | -tools-vala/hud-gtk.ui |
21 | -src/hud.interface.c |
22 | src/indicator-appmenu-marshal.c |
23 | |
24 | === modified file 'po/indicator-appmenu.pot' |
25 | --- po/indicator-appmenu.pot 2012-11-22 12:48:46 +0000 |
26 | +++ po/indicator-appmenu.pot 2014-03-21 10:25:21 +0000 |
27 | @@ -8,7 +8,7 @@ |
28 | msgstr "" |
29 | "Project-Id-Version: PACKAGE VERSION\n" |
30 | "Report-Msgid-Bugs-To: \n" |
31 | -"POT-Creation-Date: 2012-11-22 12:51+0100\n" |
32 | +"POT-Creation-Date: 2014-03-21 11:22+0100\n" |
33 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
34 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
35 | "Language-Team: LANGUAGE <LL@li.org>\n" |
36 | @@ -18,129 +18,13 @@ |
37 | "Content-Transfer-Encoding: 8bit\n" |
38 | |
39 | #: ../data/com.canonical.indicator.appmenu.gschema.xml.h:1 |
40 | -msgid "Where the menus displayed" |
41 | +msgid "Where the menu is displayed." |
42 | msgstr "" |
43 | |
44 | #: ../data/com.canonical.indicator.appmenu.gschema.xml.h:2 |
45 | -msgid "Controls the menu display location. TODO: add more" |
46 | -msgstr "" |
47 | - |
48 | -#: ../data/com.canonical.indicator.appmenu.hud.gschema.xml.h:1 |
49 | -msgid "Whether to store usage data" |
50 | -msgstr "" |
51 | - |
52 | -#: ../data/com.canonical.indicator.appmenu.hud.gschema.xml.h:2 |
53 | -msgid "" |
54 | -"When the HUD executes operations it stores the execution in order to make " |
55 | -"the future results better. Some users could choose to not want this data to " |
56 | -"be stored. If that is the case they should disable this property." |
57 | -msgstr "" |
58 | - |
59 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:1 |
60 | -msgid "The penalty given to a menu item being in an indicator" |
61 | -msgstr "" |
62 | - |
63 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:3 |
64 | -#, no-c-format |
65 | -msgid "" |
66 | -"In order to have the application's menu items appear higher in the search " |
67 | -"results a slight penalty is given to the indicator menu items. This value " |
68 | -"represents the percentage of that penalty so a value of '50' is a 50% " |
69 | -"additional to the calculated distance." |
70 | -msgstr "" |
71 | - |
72 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:4 |
73 | -msgid "Penalty for extra characters added to the search" |
74 | -msgstr "" |
75 | - |
76 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:5 |
77 | -msgid "" |
78 | -"The penalty for each extra character in the search string that does not " |
79 | -"appear in the text of a menu item.\n" |
80 | -"\n" |
81 | -"This penalty would be applied if the user typed \"fiile\" when searching " |
82 | -"against the menu item \"File\", for example." |
83 | -msgstr "" |
84 | - |
85 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:8 |
86 | -msgid "Penalty applied if a character is dropped" |
87 | -msgstr "" |
88 | - |
89 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:9 |
90 | -msgid "" |
91 | -"The penalty for each character dropped from the search string, as compared " |
92 | -"with the text of a menu item. This only applies to missing characters that " |
93 | -"are not at the end of the search term.\n" |
94 | -"\n" |
95 | -"This penalty would be applied if the user typed \"fle\" when searching " |
96 | -"against the menu item \"File\", for example." |
97 | -msgstr "" |
98 | - |
99 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:12 |
100 | -msgid "Penalty applied if a character is dropped from the end" |
101 | -msgstr "" |
102 | - |
103 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:13 |
104 | -msgid "" |
105 | -"The penalty for each missing character at the end of a search term.\n" |
106 | -"\n" |
107 | -"This penalty would be applied if the user typed \"fil\" when searching " |
108 | -"against the menu item \"File\", for example." |
109 | -msgstr "" |
110 | - |
111 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:16 |
112 | -msgid "Penalty applied when the characters are not the same" |
113 | -msgstr "" |
114 | - |
115 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:17 |
116 | -msgid "" |
117 | -"The penalty for each substituted character in the search term.\n" |
118 | -"\n" |
119 | -"The penalty would be applied if the user typed \"fike\" when searching " |
120 | -"against the menu item \"File\", for example." |
121 | -msgstr "" |
122 | - |
123 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:20 |
124 | -msgid "The highest distance value that is shown in the results" |
125 | -msgstr "" |
126 | - |
127 | -#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:21 |
128 | -msgid "" |
129 | -"After the distances are calculated (including the indicator penalty) then " |
130 | -"all values above this max are dropped. This means that the history for those " |
131 | -"entries aren't looked up as well." |
132 | -msgstr "" |
133 | - |
134 | -#. TRANSLATORS: This is used for Application indicators that |
135 | -#. are not providing a title string. The '%s' represents the |
136 | -#. unique ID that the app indicator provides, but it is usually |
137 | -#. the package name and not generally human readable. An example |
138 | -#. for Network Manager would be 'nm-applet'. |
139 | -#: ../src/hudappindicatorsource.c:105 |
140 | -#, c-format |
141 | -msgid "Untitled Indicator (%s)" |
142 | -msgstr "" |
143 | - |
144 | -#: ../src/hudindicatorsource.c:61 |
145 | -msgid "Date" |
146 | -msgstr "" |
147 | - |
148 | -#: ../src/hudindicatorsource.c:68 |
149 | -msgid "Device" |
150 | -msgstr "" |
151 | - |
152 | -#: ../src/hudindicatorsource.c:75 |
153 | -msgid "Users" |
154 | -msgstr "" |
155 | - |
156 | -#: ../src/hudindicatorsource.c:82 |
157 | -msgid "Sound" |
158 | -msgstr "" |
159 | - |
160 | -#: ../src/hudindicatorsource.c:89 |
161 | -msgid "Messages" |
162 | -msgstr "" |
163 | - |
164 | -#: ../src/window-menu-model.c:162 |
165 | +msgid "Controls the menu display location." |
166 | +msgstr "" |
167 | + |
168 | +#: ../src/window-menu-model.c:170 |
169 | msgid "Unknown Application Name" |
170 | msgstr "" |
171 | |
172 | === removed file 'src/usage-tracker.c' |
173 | --- src/usage-tracker.c 2013-02-06 15:25:03 +0000 |
174 | +++ src/usage-tracker.c 1970-01-01 00:00:00 +0000 |
175 | @@ -1,510 +0,0 @@ |
176 | -/* |
177 | -Tracks which menu items get used by users and works to promote those |
178 | -higher in the search rankings than others. |
179 | - |
180 | -Copyright 2011 Canonical Ltd. |
181 | - |
182 | -Authors: |
183 | - Ted Gould <ted@canonical.com> |
184 | - |
185 | -This program is free software: you can redistribute it and/or modify it |
186 | -under the terms of the GNU General Public License version 3, as published |
187 | -by the Free Software Foundation. |
188 | - |
189 | -This program is distributed in the hope that it will be useful, but |
190 | -WITHOUT ANY WARRANTY; without even the implied warranties of |
191 | -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
192 | -PURPOSE. See the GNU General Public License for more details. |
193 | - |
194 | -You should have received a copy of the GNU General Public License along |
195 | -with this program. If not, see <http://www.gnu.org/licenses/>. |
196 | -*/ |
197 | - |
198 | -#define G_LOG_DOMAIN "usagetracker" |
199 | - |
200 | -#ifdef HAVE_CONFIG_H |
201 | -#include "config.h" |
202 | -#endif |
203 | - |
204 | -#include "usage-tracker.h" |
205 | - |
206 | -#include <glib.h> |
207 | -#include <glib/gstdio.h> |
208 | -#include <gio/gio.h> |
209 | -#include <sqlite3.h> |
210 | -#include "load-app-info.h" |
211 | -#include "create-db.h" |
212 | -#include "hudsettings.h" |
213 | - |
214 | -struct _UsageTrackerPrivate { |
215 | - gchar * cachefile; |
216 | - sqlite3 * db; |
217 | - guint drop_timer; |
218 | - |
219 | - /* SQL Statements */ |
220 | - sqlite3_stmt * insert_entry; |
221 | - sqlite3_stmt * entry_count; |
222 | - sqlite3_stmt * delete_aged; |
223 | - sqlite3_stmt * application_count; |
224 | -}; |
225 | - |
226 | -typedef enum { |
227 | - SQL_VAR_APPLICATION = 1, |
228 | - SQL_VAR_ENTRY = 2 |
229 | -} sql_variables; |
230 | - |
231 | -#define SQL_VARS_APPLICATION "1" |
232 | -#define SQL_VARS_ENTRY "2" |
233 | - |
234 | -#define USAGE_TRACKER_GET_PRIVATE(o) \ |
235 | -(G_TYPE_INSTANCE_GET_PRIVATE ((o), USAGE_TRACKER_TYPE, UsageTrackerPrivate)) |
236 | - |
237 | -static void usage_tracker_dispose (GObject *object); |
238 | -static void usage_tracker_finalize (GObject *object); |
239 | -static void cleanup_db (UsageTracker * self); |
240 | -static void configure_db (UsageTracker * self); |
241 | -static void prepare_statements (UsageTracker * self); |
242 | -static void build_db (UsageTracker * self); |
243 | -static gboolean drop_entries (gpointer user_data); |
244 | -static void check_app_init (UsageTracker * self, const gchar * application); |
245 | - |
246 | -G_DEFINE_TYPE (UsageTracker, usage_tracker, G_TYPE_OBJECT); |
247 | - |
248 | -static void |
249 | -usage_tracker_class_init (UsageTrackerClass *klass) |
250 | -{ |
251 | - GObjectClass *object_class = G_OBJECT_CLASS (klass); |
252 | - |
253 | - g_type_class_add_private (klass, sizeof (UsageTrackerPrivate)); |
254 | - |
255 | - object_class->dispose = usage_tracker_dispose; |
256 | - object_class->finalize = usage_tracker_finalize; |
257 | - |
258 | - return; |
259 | -} |
260 | - |
261 | -static void |
262 | -usage_tracker_init (UsageTracker *self) |
263 | -{ |
264 | - self->priv = USAGE_TRACKER_GET_PRIVATE(self); |
265 | - |
266 | - self->priv->cachefile = NULL; |
267 | - self->priv->db = NULL; |
268 | - self->priv->drop_timer = 0; |
269 | - |
270 | - self->priv->insert_entry = NULL; |
271 | - self->priv->entry_count = NULL; |
272 | - self->priv->delete_aged = NULL; |
273 | - self->priv->application_count = NULL; |
274 | - |
275 | - configure_db(self); |
276 | - |
277 | - /* Drop entries daily if we run for a really long time */ |
278 | - self->priv->drop_timer = g_timeout_add_seconds(24 * 60 * 60, drop_entries, self); |
279 | - |
280 | - return; |
281 | -} |
282 | - |
283 | -static void |
284 | -usage_tracker_dispose (GObject *object) |
285 | -{ |
286 | - UsageTracker * self = USAGE_TRACKER(object); |
287 | - |
288 | - cleanup_db(self); |
289 | - |
290 | - if (self->priv->drop_timer != 0) { |
291 | - g_source_remove(self->priv->drop_timer); |
292 | - self->priv->drop_timer = 0; |
293 | - } |
294 | - |
295 | - G_OBJECT_CLASS (usage_tracker_parent_class)->dispose (object); |
296 | - return; |
297 | -} |
298 | - |
299 | -static void |
300 | -usage_tracker_finalize (GObject *object) |
301 | -{ |
302 | - UsageTracker * self = USAGE_TRACKER(object); |
303 | - |
304 | - if (self->priv->cachefile != NULL) { |
305 | - g_free(self->priv->cachefile); |
306 | - self->priv->cachefile = NULL; |
307 | - } |
308 | - |
309 | - G_OBJECT_CLASS (usage_tracker_parent_class)->finalize (object); |
310 | - return; |
311 | -} |
312 | - |
313 | -/* Small function to make sure we get all the DB components cleaned |
314 | - up in the spaces we need them */ |
315 | -static void |
316 | -cleanup_db (UsageTracker * self) |
317 | -{ |
318 | - if (self->priv->insert_entry != NULL) { |
319 | - sqlite3_finalize(self->priv->insert_entry); |
320 | - self->priv->insert_entry = NULL; |
321 | - } |
322 | - |
323 | - if (self->priv->entry_count != NULL) { |
324 | - sqlite3_finalize(self->priv->entry_count); |
325 | - self->priv->entry_count = NULL; |
326 | - } |
327 | - |
328 | - if (self->priv->delete_aged != NULL) { |
329 | - sqlite3_finalize(self->priv->delete_aged); |
330 | - self->priv->delete_aged = NULL; |
331 | - } |
332 | - |
333 | - if (self->priv->application_count != NULL) { |
334 | - sqlite3_finalize(self->priv->application_count); |
335 | - self->priv->application_count = NULL; |
336 | - } |
337 | - |
338 | - if (self->priv->db != NULL) { |
339 | - sqlite3_close(self->priv->db); |
340 | - self->priv->db = NULL; |
341 | - } |
342 | - |
343 | - return; |
344 | -} |
345 | - |
346 | -UsageTracker * |
347 | -usage_tracker_new (void) |
348 | -{ |
349 | - return g_object_new(USAGE_TRACKER_TYPE, NULL); |
350 | -} |
351 | - |
352 | -/* Configure which database we should be using */ |
353 | -static void |
354 | -configure_db (UsageTracker * self) |
355 | -{ |
356 | - /* Removing the previous database */ |
357 | - cleanup_db(self); |
358 | - |
359 | - if (self->priv->cachefile != NULL) { |
360 | - g_free(self->priv->cachefile); |
361 | - self->priv->cachefile = NULL; |
362 | - } |
363 | - |
364 | - /* Determine where his database should be built */ |
365 | - gboolean usage_data = hud_settings.store_usage_data; |
366 | - |
367 | - if (g_getenv("HUD_NO_STORE_USAGE_DATA") != NULL) { |
368 | - usage_data = FALSE; |
369 | - } |
370 | - |
371 | - if (usage_data) { |
372 | - g_debug("Storing usage data on filesystem"); |
373 | - } |
374 | - |
375 | - /* Setting up the new database */ |
376 | - gboolean db_exists = FALSE; |
377 | - |
378 | - if (usage_data) { |
379 | - /* If we're storing the usage data we need to figure out |
380 | - how to do it on disk */ |
381 | - |
382 | - const gchar * basecachedir = g_getenv("HUD_CACHE_DIR"); |
383 | - if (basecachedir == NULL) { |
384 | - basecachedir = g_get_user_cache_dir(); |
385 | - } |
386 | - |
387 | - gchar * cachedir = g_build_filename(basecachedir, "indicator-appmenu", NULL); |
388 | - if (!g_file_test(cachedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { |
389 | - if (g_mkdir(cachedir, 00700) != 0) { |
390 | - g_warning("Could not create cache directory, LRU DB can't be created"); |
391 | - self->priv->db = NULL; |
392 | - g_free(cachedir); |
393 | - return; |
394 | - } |
395 | - } |
396 | - g_free(cachedir); |
397 | - |
398 | - self->priv->cachefile = g_build_filename(basecachedir, "indicator-appmenu", "hud-usage-log.sqlite", NULL); |
399 | - db_exists = g_file_test(self->priv->cachefile, G_FILE_TEST_EXISTS); |
400 | - int open_status = sqlite3_open(self->priv->cachefile, &self->priv->db); |
401 | - |
402 | - if (open_status != SQLITE_OK) { |
403 | - g_warning("Error building LRU DB"); |
404 | - sqlite3_close(self->priv->db); |
405 | - self->priv->db = NULL; |
406 | - } |
407 | - } else { |
408 | - /* If we're not storing it, let's make an in memory database |
409 | - so that we can use the app-info, and get better, but we don't |
410 | - give anyone that data. */ |
411 | - self->priv->cachefile = g_strdup(":memory:"); |
412 | - |
413 | - int open_status = sqlite3_open(self->priv->cachefile, &self->priv->db); |
414 | - |
415 | - if (open_status != SQLITE_OK) { |
416 | - g_warning("Error building LRU DB"); |
417 | - sqlite3_close(self->priv->db); |
418 | - self->priv->db = NULL; |
419 | - } |
420 | - } |
421 | - |
422 | - if (self->priv->db != NULL && !db_exists) { |
423 | - build_db(self); |
424 | - } |
425 | - |
426 | - prepare_statements(self); |
427 | - |
428 | - drop_entries(self); |
429 | - |
430 | - return; |
431 | -} |
432 | - |
433 | -/* Build all the prepared statments */ |
434 | -static void |
435 | -prepare_statements (UsageTracker * self) |
436 | -{ |
437 | - if (self->priv->db == NULL) { |
438 | - return; |
439 | - } |
440 | - |
441 | - /* These should never happen, but let's just check to make sure */ |
442 | - g_return_if_fail(self->priv->insert_entry == NULL); |
443 | - g_return_if_fail(self->priv->entry_count == NULL); |
444 | - g_return_if_fail(self->priv->delete_aged == NULL); |
445 | - g_return_if_fail(self->priv->application_count == NULL); |
446 | - |
447 | - int prepare_status = SQLITE_OK; |
448 | - |
449 | - /* Insert Statement */ |
450 | - prepare_status = sqlite3_prepare_v2(self->priv->db, |
451 | - "insert into usage (application, entry, timestamp) values (?" SQL_VARS_APPLICATION ", ?" SQL_VARS_ENTRY ", date('now', 'utc'));", |
452 | - -1, /* length */ |
453 | - &(self->priv->insert_entry), |
454 | - NULL); /* unused stmt */ |
455 | - |
456 | - if (prepare_status != SQLITE_OK) { |
457 | - g_warning("Unable to prepare insert entry statement: %s", sqlite3_errmsg(self->priv->db)); |
458 | - self->priv->insert_entry = NULL; |
459 | - } |
460 | - |
461 | - /* Entry Count Statement */ |
462 | - prepare_status = sqlite3_prepare_v2(self->priv->db, |
463 | - "select count(*) from usage where application = ?" SQL_VARS_APPLICATION " and entry = ?" SQL_VARS_ENTRY " and timestamp > date('now', 'utc', '-30 days');", |
464 | - -1, /* length */ |
465 | - &(self->priv->entry_count), |
466 | - NULL); /* unused stmt */ |
467 | - |
468 | - if (prepare_status != SQLITE_OK) { |
469 | - g_warning("Unable to prepare entry count statement: %s", sqlite3_errmsg(self->priv->db)); |
470 | - self->priv->entry_count = NULL; |
471 | - } |
472 | - |
473 | - /* Delete Aged Statement */ |
474 | - prepare_status = sqlite3_prepare_v2(self->priv->db, |
475 | - "delete from usage where timestamp < date('now', 'utc', '-30 days');", |
476 | - -1, /* length */ |
477 | - &(self->priv->delete_aged), |
478 | - NULL); /* unused stmt */ |
479 | - |
480 | - if (prepare_status != SQLITE_OK) { |
481 | - g_warning("Unable to prepare delete aged statement: %s", sqlite3_errmsg(self->priv->db)); |
482 | - self->priv->delete_aged = NULL; |
483 | - } |
484 | - |
485 | - /* Application Count Statement */ |
486 | - prepare_status = sqlite3_prepare_v2(self->priv->db, |
487 | - "select count(*) from usage where application = ?" SQL_VARS_APPLICATION ";", |
488 | - -1, /* length */ |
489 | - &(self->priv->application_count), |
490 | - NULL); /* unused stmt */ |
491 | - |
492 | - if (prepare_status != SQLITE_OK) { |
493 | - g_warning("Unable to prepare application count statement: %s", sqlite3_errmsg(self->priv->db)); |
494 | - self->priv->application_count = NULL; |
495 | - } |
496 | - |
497 | - return; |
498 | -} |
499 | - |
500 | -/* Build the database */ |
501 | -static void |
502 | -build_db (UsageTracker * self) |
503 | -{ |
504 | - g_debug("New database, initializing"); |
505 | - |
506 | - /* Create the table */ |
507 | - int exec_status = SQLITE_OK; |
508 | - gchar * failstring = NULL; |
509 | - exec_status = sqlite3_exec(self->priv->db, |
510 | - create_db, |
511 | - NULL, NULL, &failstring); |
512 | - if (exec_status != SQLITE_OK) { |
513 | - g_warning("Unable to create table: %s", failstring); |
514 | - } |
515 | - |
516 | - return; |
517 | -} |
518 | - |
519 | -void |
520 | -usage_tracker_mark_usage (UsageTracker * self, const gchar * application, const gchar * entry) |
521 | -{ |
522 | - g_return_if_fail(IS_USAGE_TRACKER(self)); |
523 | - g_return_if_fail(self->priv->db != NULL); |
524 | - |
525 | - g_debug ("Marking %s %s", application, entry); |
526 | - |
527 | - check_app_init(self, application); |
528 | - |
529 | - sqlite3_reset(self->priv->insert_entry); |
530 | - |
531 | - int bind_status = SQLITE_OK; |
532 | - |
533 | - bind_status = sqlite3_bind_text(self->priv->insert_entry, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT); |
534 | - if (bind_status != SQLITE_OK) { |
535 | - g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db)); |
536 | - return; |
537 | - } |
538 | - |
539 | - bind_status = sqlite3_bind_text(self->priv->insert_entry, SQL_VAR_ENTRY, entry, -1, SQLITE_TRANSIENT); |
540 | - if (bind_status != SQLITE_OK) { |
541 | - g_warning("Unable to bind entry info: %s", sqlite3_errmsg(self->priv->db)); |
542 | - return; |
543 | - } |
544 | - |
545 | - int exec_status = SQLITE_ROW; |
546 | - while ((exec_status = sqlite3_step(self->priv->insert_entry)) == SQLITE_ROW) { |
547 | - } |
548 | - |
549 | - if (exec_status != SQLITE_DONE) { |
550 | - g_warning("Unknown status from executing insert_entry: %d", exec_status); |
551 | - } |
552 | - |
553 | - return; |
554 | -} |
555 | - |
556 | -guint |
557 | -usage_tracker_get_usage (UsageTracker * self, const gchar * application, const gchar * entry) |
558 | -{ |
559 | - g_return_val_if_fail(IS_USAGE_TRACKER(self), 0); |
560 | - g_return_val_if_fail(self->priv->db != NULL, 0); |
561 | - |
562 | - check_app_init(self, application); |
563 | - |
564 | - sqlite3_reset(self->priv->entry_count); |
565 | - |
566 | - int bind_status = SQLITE_OK; |
567 | - |
568 | - bind_status = sqlite3_bind_text(self->priv->entry_count, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT); |
569 | - if (bind_status != SQLITE_OK) { |
570 | - g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db)); |
571 | - return 0; |
572 | - } |
573 | - |
574 | - bind_status = sqlite3_bind_text(self->priv->entry_count, SQL_VAR_ENTRY, entry, -1, SQLITE_TRANSIENT); |
575 | - if (bind_status != SQLITE_OK) { |
576 | - g_warning("Unable to bind entry info: %s", sqlite3_errmsg(self->priv->db)); |
577 | - return 0; |
578 | - } |
579 | - |
580 | - int exec_status = SQLITE_ROW; |
581 | - guint count = 0; |
582 | - |
583 | - while ((exec_status = sqlite3_step(self->priv->entry_count)) == SQLITE_ROW) { |
584 | - count = sqlite3_column_int(self->priv->entry_count, 0); |
585 | - } |
586 | - |
587 | - if (exec_status != SQLITE_DONE) { |
588 | - g_warning("Unknown status from executing entry_count: %d", exec_status); |
589 | - } |
590 | - |
591 | - g_debug ("Usage of %s %s is %u", application, entry, count); |
592 | - |
593 | - return count; |
594 | -} |
595 | - |
596 | -/* Drop the entries from the database that have expired as they are |
597 | - over 30 days old */ |
598 | -static gboolean |
599 | -drop_entries (gpointer user_data) |
600 | -{ |
601 | - g_return_val_if_fail(IS_USAGE_TRACKER(user_data), FALSE); |
602 | - UsageTracker * self = USAGE_TRACKER(user_data); |
603 | - |
604 | - if (self->priv->db == NULL) { |
605 | - return TRUE; |
606 | - } |
607 | - |
608 | - sqlite3_reset(self->priv->delete_aged); |
609 | - |
610 | - int exec_status = SQLITE_ROW; |
611 | - while ((exec_status = sqlite3_step(self->priv->delete_aged)) == SQLITE_ROW) { |
612 | - } |
613 | - |
614 | - if (exec_status != SQLITE_DONE) { |
615 | - g_warning("Unknown status from executing delete_aged: %d", exec_status); |
616 | - } |
617 | - |
618 | - return TRUE; |
619 | -} |
620 | - |
621 | -static void |
622 | -check_app_init (UsageTracker * self, const gchar * application) |
623 | -{ |
624 | - sqlite3_reset(self->priv->application_count); |
625 | - |
626 | - int bind_status = SQLITE_OK; |
627 | - bind_status = sqlite3_bind_text(self->priv->application_count, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT); |
628 | - if (bind_status != SQLITE_OK) { |
629 | - g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db)); |
630 | - return; |
631 | - } |
632 | - |
633 | - int exec_status = SQLITE_ROW; |
634 | - guint count = 0; |
635 | - |
636 | - while ((exec_status = sqlite3_step(self->priv->application_count)) == SQLITE_ROW) { |
637 | - count = sqlite3_column_int(self->priv->application_count, 0); |
638 | - } |
639 | - |
640 | - if (exec_status != SQLITE_DONE) { |
641 | - g_warning("Unknown status from executing application_count: %d", exec_status); |
642 | - } |
643 | - |
644 | - if (count > 0) { |
645 | - return; |
646 | - } |
647 | - |
648 | - g_debug("Initializing application: %s", application); |
649 | - gchar * basename = g_path_get_basename(application); |
650 | - |
651 | - gchar * app_info_path = NULL; |
652 | - |
653 | - if (g_getenv("HUD_APP_INFO_DIR") != NULL) { |
654 | - app_info_path = g_strdup(g_getenv("HUD_APP_INFO_DIR")); |
655 | - } else { |
656 | - app_info_path = g_build_filename(DATADIR, "indicator-appmenu", "hud", "app-info", NULL); |
657 | - } |
658 | - |
659 | - gchar * app_info_filename = g_strdup_printf("%s.hud-app-info", basename); |
660 | - gchar * app_info = g_build_filename(app_info_path, app_info_filename, NULL); |
661 | - |
662 | - if (!load_app_info(app_info, self->priv->db)) { |
663 | - if (g_file_test(app_info, G_FILE_TEST_EXISTS)) { |
664 | - g_warning("Unable to load application information for application '%s' at path '%s'", application, app_info); |
665 | - } |
666 | - } |
667 | - |
668 | - g_free(app_info); |
669 | - g_free(app_info_filename); |
670 | - g_free(app_info_path); |
671 | - g_free(basename); |
672 | - |
673 | - return; |
674 | -} |
675 | - |
676 | -UsageTracker * |
677 | -usage_tracker_get_instance (void) |
678 | -{ |
679 | - static UsageTracker *usage_tracker_instance; |
680 | - |
681 | - if (usage_tracker_instance == NULL) |
682 | - usage_tracker_instance = usage_tracker_new (); |
683 | - |
684 | - return usage_tracker_instance; |
685 | -} |
686 | |
687 | === removed file 'src/usage-tracker.h' |
688 | --- src/usage-tracker.h 2012-02-28 15:22:00 +0000 |
689 | +++ src/usage-tracker.h 1970-01-01 00:00:00 +0000 |
690 | @@ -1,59 +0,0 @@ |
691 | -/* |
692 | -Tracks which menu items get used by users and works to promote those |
693 | -higher in the search rankings than others. |
694 | - |
695 | -Copyright 2011 Canonical Ltd. |
696 | - |
697 | -Authors: |
698 | - Ted Gould <ted@canonical.com> |
699 | - |
700 | -This program is free software: you can redistribute it and/or modify it |
701 | -under the terms of the GNU General Public License version 3, as published |
702 | -by the Free Software Foundation. |
703 | - |
704 | -This program is distributed in the hope that it will be useful, but |
705 | -WITHOUT ANY WARRANTY; without even the implied warranties of |
706 | -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
707 | -PURPOSE. See the GNU General Public License for more details. |
708 | - |
709 | -You should have received a copy of the GNU General Public License along |
710 | -with this program. If not, see <http://www.gnu.org/licenses/>. |
711 | -*/ |
712 | - |
713 | -#ifndef __USAGE_TRACKER_H__ |
714 | -#define __USAGE_TRACKER_H__ |
715 | - |
716 | -#include <glib-object.h> |
717 | - |
718 | -G_BEGIN_DECLS |
719 | - |
720 | -#define USAGE_TRACKER_TYPE (usage_tracker_get_type ()) |
721 | -#define USAGE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USAGE_TRACKER_TYPE, UsageTracker)) |
722 | -#define USAGE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USAGE_TRACKER_TYPE, UsageTrackerClass)) |
723 | -#define IS_USAGE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USAGE_TRACKER_TYPE)) |
724 | -#define IS_USAGE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USAGE_TRACKER_TYPE)) |
725 | -#define USAGE_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USAGE_TRACKER_TYPE, UsageTrackerClass)) |
726 | - |
727 | -typedef struct _UsageTracker UsageTracker; |
728 | -typedef struct _UsageTrackerClass UsageTrackerClass; |
729 | -typedef struct _UsageTrackerPrivate UsageTrackerPrivate; |
730 | - |
731 | -struct _UsageTrackerClass { |
732 | - GObjectClass parent_class; |
733 | -}; |
734 | - |
735 | -struct _UsageTracker { |
736 | - GObject parent; |
737 | - |
738 | - UsageTrackerPrivate * priv; |
739 | -}; |
740 | - |
741 | -GType usage_tracker_get_type (void); |
742 | -UsageTracker * usage_tracker_new (void); |
743 | -void usage_tracker_mark_usage (UsageTracker * self, const gchar * application, const gchar * entry); |
744 | -guint usage_tracker_get_usage (UsageTracker * self, const gchar * application, const gchar * entry); |
745 | -UsageTracker * usage_tracker_get_instance (void); |
746 | - |
747 | -G_END_DECLS |
748 | - |
749 | -#endif |
PASSED: Continuous integration, rev:259 jenkins. qa.ubuntu. com/job/ indicator- appmenu- ci/21/ jenkins. qa.ubuntu. com/job/ indicator- appmenu- trusty- amd64-ci/ 16 jenkins. qa.ubuntu. com/job/ indicator- appmenu- trusty- armhf-ci/ 16 jenkins. qa.ubuntu. com/job/ indicator- appmenu- trusty- armhf-ci/ 16/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- appmenu- ci/21/rebuild
http://