Merge lp:~seb128/indicator-appmenu/clean-hud-leftover into lp:indicator-appmenu/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
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
=== modified file 'debian/control'
--- debian/control 2013-07-22 04:46:18 +0000
+++ debian/control 2014-03-21 10:25:21 +0000
@@ -30,7 +30,6 @@
30Architecture: any30Architecture: any
31Depends: ${shlibs:Depends},31Depends: ${shlibs:Depends},
32 ${misc:Depends},32 ${misc:Depends},
33 hud,
34Recommends: indicator-applet | indicator-renderer,33Recommends: indicator-applet | indicator-renderer,
35 unity-gtk2-module,34 unity-gtk2-module,
36 unity-gtk3-module,35 unity-gtk3-module,
3736
=== modified file 'po/POTFILES.skip'
--- po/POTFILES.skip 2012-03-21 17:31:16 +0000
+++ po/POTFILES.skip 2014-03-21 10:25:21 +0000
@@ -1,6 +1,4 @@
1src/create-db.c1src/create-db.c
2src/gen-application-menu-registrar.xml.c2src/gen-application-menu-registrar.xml.c
3src/gen-application-menu-renderer.xml.c3src/gen-application-menu-renderer.xml.c
4tools-vala/hud-gtk.ui
5src/hud.interface.c
6src/indicator-appmenu-marshal.c4src/indicator-appmenu-marshal.c
75
=== modified file 'po/indicator-appmenu.pot'
--- po/indicator-appmenu.pot 2012-11-22 12:48:46 +0000
+++ po/indicator-appmenu.pot 2014-03-21 10:25:21 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2012-11-22 12:51+0100\n"11"POT-Creation-Date: 2014-03-21 11:22+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,129 +18,13 @@
18"Content-Transfer-Encoding: 8bit\n"18"Content-Transfer-Encoding: 8bit\n"
1919
20#: ../data/com.canonical.indicator.appmenu.gschema.xml.h:120#: ../data/com.canonical.indicator.appmenu.gschema.xml.h:1
21msgid "Where the menus displayed"21msgid "Where the menu is displayed."
22msgstr ""22msgstr ""
2323
24#: ../data/com.canonical.indicator.appmenu.gschema.xml.h:224#: ../data/com.canonical.indicator.appmenu.gschema.xml.h:2
25msgid "Controls the menu display location. TODO: add more"25msgid "Controls the menu display location."
26msgstr ""26msgstr ""
2727
28#: ../data/com.canonical.indicator.appmenu.hud.gschema.xml.h:128#: ../src/window-menu-model.c:170
29msgid "Whether to store usage data"
30msgstr ""
31
32#: ../data/com.canonical.indicator.appmenu.hud.gschema.xml.h:2
33msgid ""
34"When the HUD executes operations it stores the execution in order to make "
35"the future results better. Some users could choose to not want this data to "
36"be stored. If that is the case they should disable this property."
37msgstr ""
38
39#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:1
40msgid "The penalty given to a menu item being in an indicator"
41msgstr ""
42
43#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:3
44#, no-c-format
45msgid ""
46"In order to have the application's menu items appear higher in the search "
47"results a slight penalty is given to the indicator menu items. This value "
48"represents the percentage of that penalty so a value of '50' is a 50% "
49"additional to the calculated distance."
50msgstr ""
51
52#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:4
53msgid "Penalty for extra characters added to the search"
54msgstr ""
55
56#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:5
57msgid ""
58"The penalty for each extra character in the search string that does not "
59"appear in the text of a menu item.\n"
60"\n"
61"This penalty would be applied if the user typed \"fiile\" when searching "
62"against the menu item \"File\", for example."
63msgstr ""
64
65#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:8
66msgid "Penalty applied if a character is dropped"
67msgstr ""
68
69#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:9
70msgid ""
71"The penalty for each character dropped from the search string, as compared "
72"with the text of a menu item. This only applies to missing characters that "
73"are not at the end of the search term.\n"
74"\n"
75"This penalty would be applied if the user typed \"fle\" when searching "
76"against the menu item \"File\", for example."
77msgstr ""
78
79#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:12
80msgid "Penalty applied if a character is dropped from the end"
81msgstr ""
82
83#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:13
84msgid ""
85"The penalty for each missing character at the end of a search term.\n"
86"\n"
87"This penalty would be applied if the user typed \"fil\" when searching "
88"against the menu item \"File\", for example."
89msgstr ""
90
91#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:16
92msgid "Penalty applied when the characters are not the same"
93msgstr ""
94
95#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:17
96msgid ""
97"The penalty for each substituted character in the search term.\n"
98"\n"
99"The penalty would be applied if the user typed \"fike\" when searching "
100"against the menu item \"File\", for example."
101msgstr ""
102
103#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:20
104msgid "The highest distance value that is shown in the results"
105msgstr ""
106
107#: ../data/com.canonical.indicator.appmenu.hud.search.gschema.xml.h:21
108msgid ""
109"After the distances are calculated (including the indicator penalty) then "
110"all values above this max are dropped. This means that the history for those "
111"entries aren't looked up as well."
112msgstr ""
113
114#. TRANSLATORS: This is used for Application indicators that
115#. are not providing a title string. The '%s' represents the
116#. unique ID that the app indicator provides, but it is usually
117#. the package name and not generally human readable. An example
118#. for Network Manager would be 'nm-applet'.
119#: ../src/hudappindicatorsource.c:105
120#, c-format
121msgid "Untitled Indicator (%s)"
122msgstr ""
123
124#: ../src/hudindicatorsource.c:61
125msgid "Date"
126msgstr ""
127
128#: ../src/hudindicatorsource.c:68
129msgid "Device"
130msgstr ""
131
132#: ../src/hudindicatorsource.c:75
133msgid "Users"
134msgstr ""
135
136#: ../src/hudindicatorsource.c:82
137msgid "Sound"
138msgstr ""
139
140#: ../src/hudindicatorsource.c:89
141msgid "Messages"
142msgstr ""
143
144#: ../src/window-menu-model.c:162
145msgid "Unknown Application Name"29msgid "Unknown Application Name"
146msgstr ""30msgstr ""
14731
=== removed file 'src/usage-tracker.c'
--- src/usage-tracker.c 2013-02-06 15:25:03 +0000
+++ src/usage-tracker.c 1970-01-01 00:00:00 +0000
@@ -1,510 +0,0 @@
1/*
2Tracks which menu items get used by users and works to promote those
3higher in the search rankings than others.
4
5Copyright 2011 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#define G_LOG_DOMAIN "usagetracker"
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "usage-tracker.h"
30
31#include <glib.h>
32#include <glib/gstdio.h>
33#include <gio/gio.h>
34#include <sqlite3.h>
35#include "load-app-info.h"
36#include "create-db.h"
37#include "hudsettings.h"
38
39struct _UsageTrackerPrivate {
40 gchar * cachefile;
41 sqlite3 * db;
42 guint drop_timer;
43
44 /* SQL Statements */
45 sqlite3_stmt * insert_entry;
46 sqlite3_stmt * entry_count;
47 sqlite3_stmt * delete_aged;
48 sqlite3_stmt * application_count;
49};
50
51typedef enum {
52 SQL_VAR_APPLICATION = 1,
53 SQL_VAR_ENTRY = 2
54} sql_variables;
55
56#define SQL_VARS_APPLICATION "1"
57#define SQL_VARS_ENTRY "2"
58
59#define USAGE_TRACKER_GET_PRIVATE(o) \
60(G_TYPE_INSTANCE_GET_PRIVATE ((o), USAGE_TRACKER_TYPE, UsageTrackerPrivate))
61
62static void usage_tracker_dispose (GObject *object);
63static void usage_tracker_finalize (GObject *object);
64static void cleanup_db (UsageTracker * self);
65static void configure_db (UsageTracker * self);
66static void prepare_statements (UsageTracker * self);
67static void build_db (UsageTracker * self);
68static gboolean drop_entries (gpointer user_data);
69static void check_app_init (UsageTracker * self, const gchar * application);
70
71G_DEFINE_TYPE (UsageTracker, usage_tracker, G_TYPE_OBJECT);
72
73static void
74usage_tracker_class_init (UsageTrackerClass *klass)
75{
76 GObjectClass *object_class = G_OBJECT_CLASS (klass);
77
78 g_type_class_add_private (klass, sizeof (UsageTrackerPrivate));
79
80 object_class->dispose = usage_tracker_dispose;
81 object_class->finalize = usage_tracker_finalize;
82
83 return;
84}
85
86static void
87usage_tracker_init (UsageTracker *self)
88{
89 self->priv = USAGE_TRACKER_GET_PRIVATE(self);
90
91 self->priv->cachefile = NULL;
92 self->priv->db = NULL;
93 self->priv->drop_timer = 0;
94
95 self->priv->insert_entry = NULL;
96 self->priv->entry_count = NULL;
97 self->priv->delete_aged = NULL;
98 self->priv->application_count = NULL;
99
100 configure_db(self);
101
102 /* Drop entries daily if we run for a really long time */
103 self->priv->drop_timer = g_timeout_add_seconds(24 * 60 * 60, drop_entries, self);
104
105 return;
106}
107
108static void
109usage_tracker_dispose (GObject *object)
110{
111 UsageTracker * self = USAGE_TRACKER(object);
112
113 cleanup_db(self);
114
115 if (self->priv->drop_timer != 0) {
116 g_source_remove(self->priv->drop_timer);
117 self->priv->drop_timer = 0;
118 }
119
120 G_OBJECT_CLASS (usage_tracker_parent_class)->dispose (object);
121 return;
122}
123
124static void
125usage_tracker_finalize (GObject *object)
126{
127 UsageTracker * self = USAGE_TRACKER(object);
128
129 if (self->priv->cachefile != NULL) {
130 g_free(self->priv->cachefile);
131 self->priv->cachefile = NULL;
132 }
133
134 G_OBJECT_CLASS (usage_tracker_parent_class)->finalize (object);
135 return;
136}
137
138/* Small function to make sure we get all the DB components cleaned
139 up in the spaces we need them */
140static void
141cleanup_db (UsageTracker * self)
142{
143 if (self->priv->insert_entry != NULL) {
144 sqlite3_finalize(self->priv->insert_entry);
145 self->priv->insert_entry = NULL;
146 }
147
148 if (self->priv->entry_count != NULL) {
149 sqlite3_finalize(self->priv->entry_count);
150 self->priv->entry_count = NULL;
151 }
152
153 if (self->priv->delete_aged != NULL) {
154 sqlite3_finalize(self->priv->delete_aged);
155 self->priv->delete_aged = NULL;
156 }
157
158 if (self->priv->application_count != NULL) {
159 sqlite3_finalize(self->priv->application_count);
160 self->priv->application_count = NULL;
161 }
162
163 if (self->priv->db != NULL) {
164 sqlite3_close(self->priv->db);
165 self->priv->db = NULL;
166 }
167
168 return;
169}
170
171UsageTracker *
172usage_tracker_new (void)
173{
174 return g_object_new(USAGE_TRACKER_TYPE, NULL);
175}
176
177/* Configure which database we should be using */
178static void
179configure_db (UsageTracker * self)
180{
181 /* Removing the previous database */
182 cleanup_db(self);
183
184 if (self->priv->cachefile != NULL) {
185 g_free(self->priv->cachefile);
186 self->priv->cachefile = NULL;
187 }
188
189 /* Determine where his database should be built */
190 gboolean usage_data = hud_settings.store_usage_data;
191
192 if (g_getenv("HUD_NO_STORE_USAGE_DATA") != NULL) {
193 usage_data = FALSE;
194 }
195
196 if (usage_data) {
197 g_debug("Storing usage data on filesystem");
198 }
199
200 /* Setting up the new database */
201 gboolean db_exists = FALSE;
202
203 if (usage_data) {
204 /* If we're storing the usage data we need to figure out
205 how to do it on disk */
206
207 const gchar * basecachedir = g_getenv("HUD_CACHE_DIR");
208 if (basecachedir == NULL) {
209 basecachedir = g_get_user_cache_dir();
210 }
211
212 gchar * cachedir = g_build_filename(basecachedir, "indicator-appmenu", NULL);
213 if (!g_file_test(cachedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
214 if (g_mkdir(cachedir, 00700) != 0) {
215 g_warning("Could not create cache directory, LRU DB can't be created");
216 self->priv->db = NULL;
217 g_free(cachedir);
218 return;
219 }
220 }
221 g_free(cachedir);
222
223 self->priv->cachefile = g_build_filename(basecachedir, "indicator-appmenu", "hud-usage-log.sqlite", NULL);
224 db_exists = g_file_test(self->priv->cachefile, G_FILE_TEST_EXISTS);
225 int open_status = sqlite3_open(self->priv->cachefile, &self->priv->db);
226
227 if (open_status != SQLITE_OK) {
228 g_warning("Error building LRU DB");
229 sqlite3_close(self->priv->db);
230 self->priv->db = NULL;
231 }
232 } else {
233 /* If we're not storing it, let's make an in memory database
234 so that we can use the app-info, and get better, but we don't
235 give anyone that data. */
236 self->priv->cachefile = g_strdup(":memory:");
237
238 int open_status = sqlite3_open(self->priv->cachefile, &self->priv->db);
239
240 if (open_status != SQLITE_OK) {
241 g_warning("Error building LRU DB");
242 sqlite3_close(self->priv->db);
243 self->priv->db = NULL;
244 }
245 }
246
247 if (self->priv->db != NULL && !db_exists) {
248 build_db(self);
249 }
250
251 prepare_statements(self);
252
253 drop_entries(self);
254
255 return;
256}
257
258/* Build all the prepared statments */
259static void
260prepare_statements (UsageTracker * self)
261{
262 if (self->priv->db == NULL) {
263 return;
264 }
265
266 /* These should never happen, but let's just check to make sure */
267 g_return_if_fail(self->priv->insert_entry == NULL);
268 g_return_if_fail(self->priv->entry_count == NULL);
269 g_return_if_fail(self->priv->delete_aged == NULL);
270 g_return_if_fail(self->priv->application_count == NULL);
271
272 int prepare_status = SQLITE_OK;
273
274 /* Insert Statement */
275 prepare_status = sqlite3_prepare_v2(self->priv->db,
276 "insert into usage (application, entry, timestamp) values (?" SQL_VARS_APPLICATION ", ?" SQL_VARS_ENTRY ", date('now', 'utc'));",
277 -1, /* length */
278 &(self->priv->insert_entry),
279 NULL); /* unused stmt */
280
281 if (prepare_status != SQLITE_OK) {
282 g_warning("Unable to prepare insert entry statement: %s", sqlite3_errmsg(self->priv->db));
283 self->priv->insert_entry = NULL;
284 }
285
286 /* Entry Count Statement */
287 prepare_status = sqlite3_prepare_v2(self->priv->db,
288 "select count(*) from usage where application = ?" SQL_VARS_APPLICATION " and entry = ?" SQL_VARS_ENTRY " and timestamp > date('now', 'utc', '-30 days');",
289 -1, /* length */
290 &(self->priv->entry_count),
291 NULL); /* unused stmt */
292
293 if (prepare_status != SQLITE_OK) {
294 g_warning("Unable to prepare entry count statement: %s", sqlite3_errmsg(self->priv->db));
295 self->priv->entry_count = NULL;
296 }
297
298 /* Delete Aged Statement */
299 prepare_status = sqlite3_prepare_v2(self->priv->db,
300 "delete from usage where timestamp < date('now', 'utc', '-30 days');",
301 -1, /* length */
302 &(self->priv->delete_aged),
303 NULL); /* unused stmt */
304
305 if (prepare_status != SQLITE_OK) {
306 g_warning("Unable to prepare delete aged statement: %s", sqlite3_errmsg(self->priv->db));
307 self->priv->delete_aged = NULL;
308 }
309
310 /* Application Count Statement */
311 prepare_status = sqlite3_prepare_v2(self->priv->db,
312 "select count(*) from usage where application = ?" SQL_VARS_APPLICATION ";",
313 -1, /* length */
314 &(self->priv->application_count),
315 NULL); /* unused stmt */
316
317 if (prepare_status != SQLITE_OK) {
318 g_warning("Unable to prepare application count statement: %s", sqlite3_errmsg(self->priv->db));
319 self->priv->application_count = NULL;
320 }
321
322 return;
323}
324
325/* Build the database */
326static void
327build_db (UsageTracker * self)
328{
329 g_debug("New database, initializing");
330
331 /* Create the table */
332 int exec_status = SQLITE_OK;
333 gchar * failstring = NULL;
334 exec_status = sqlite3_exec(self->priv->db,
335 create_db,
336 NULL, NULL, &failstring);
337 if (exec_status != SQLITE_OK) {
338 g_warning("Unable to create table: %s", failstring);
339 }
340
341 return;
342}
343
344void
345usage_tracker_mark_usage (UsageTracker * self, const gchar * application, const gchar * entry)
346{
347 g_return_if_fail(IS_USAGE_TRACKER(self));
348 g_return_if_fail(self->priv->db != NULL);
349
350 g_debug ("Marking %s %s", application, entry);
351
352 check_app_init(self, application);
353
354 sqlite3_reset(self->priv->insert_entry);
355
356 int bind_status = SQLITE_OK;
357
358 bind_status = sqlite3_bind_text(self->priv->insert_entry, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT);
359 if (bind_status != SQLITE_OK) {
360 g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db));
361 return;
362 }
363
364 bind_status = sqlite3_bind_text(self->priv->insert_entry, SQL_VAR_ENTRY, entry, -1, SQLITE_TRANSIENT);
365 if (bind_status != SQLITE_OK) {
366 g_warning("Unable to bind entry info: %s", sqlite3_errmsg(self->priv->db));
367 return;
368 }
369
370 int exec_status = SQLITE_ROW;
371 while ((exec_status = sqlite3_step(self->priv->insert_entry)) == SQLITE_ROW) {
372 }
373
374 if (exec_status != SQLITE_DONE) {
375 g_warning("Unknown status from executing insert_entry: %d", exec_status);
376 }
377
378 return;
379}
380
381guint
382usage_tracker_get_usage (UsageTracker * self, const gchar * application, const gchar * entry)
383{
384 g_return_val_if_fail(IS_USAGE_TRACKER(self), 0);
385 g_return_val_if_fail(self->priv->db != NULL, 0);
386
387 check_app_init(self, application);
388
389 sqlite3_reset(self->priv->entry_count);
390
391 int bind_status = SQLITE_OK;
392
393 bind_status = sqlite3_bind_text(self->priv->entry_count, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT);
394 if (bind_status != SQLITE_OK) {
395 g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db));
396 return 0;
397 }
398
399 bind_status = sqlite3_bind_text(self->priv->entry_count, SQL_VAR_ENTRY, entry, -1, SQLITE_TRANSIENT);
400 if (bind_status != SQLITE_OK) {
401 g_warning("Unable to bind entry info: %s", sqlite3_errmsg(self->priv->db));
402 return 0;
403 }
404
405 int exec_status = SQLITE_ROW;
406 guint count = 0;
407
408 while ((exec_status = sqlite3_step(self->priv->entry_count)) == SQLITE_ROW) {
409 count = sqlite3_column_int(self->priv->entry_count, 0);
410 }
411
412 if (exec_status != SQLITE_DONE) {
413 g_warning("Unknown status from executing entry_count: %d", exec_status);
414 }
415
416 g_debug ("Usage of %s %s is %u", application, entry, count);
417
418 return count;
419}
420
421/* Drop the entries from the database that have expired as they are
422 over 30 days old */
423static gboolean
424drop_entries (gpointer user_data)
425{
426 g_return_val_if_fail(IS_USAGE_TRACKER(user_data), FALSE);
427 UsageTracker * self = USAGE_TRACKER(user_data);
428
429 if (self->priv->db == NULL) {
430 return TRUE;
431 }
432
433 sqlite3_reset(self->priv->delete_aged);
434
435 int exec_status = SQLITE_ROW;
436 while ((exec_status = sqlite3_step(self->priv->delete_aged)) == SQLITE_ROW) {
437 }
438
439 if (exec_status != SQLITE_DONE) {
440 g_warning("Unknown status from executing delete_aged: %d", exec_status);
441 }
442
443 return TRUE;
444}
445
446static void
447check_app_init (UsageTracker * self, const gchar * application)
448{
449 sqlite3_reset(self->priv->application_count);
450
451 int bind_status = SQLITE_OK;
452 bind_status = sqlite3_bind_text(self->priv->application_count, SQL_VAR_APPLICATION, application, -1, SQLITE_TRANSIENT);
453 if (bind_status != SQLITE_OK) {
454 g_warning("Unable to bind application info: %s", sqlite3_errmsg(self->priv->db));
455 return;
456 }
457
458 int exec_status = SQLITE_ROW;
459 guint count = 0;
460
461 while ((exec_status = sqlite3_step(self->priv->application_count)) == SQLITE_ROW) {
462 count = sqlite3_column_int(self->priv->application_count, 0);
463 }
464
465 if (exec_status != SQLITE_DONE) {
466 g_warning("Unknown status from executing application_count: %d", exec_status);
467 }
468
469 if (count > 0) {
470 return;
471 }
472
473 g_debug("Initializing application: %s", application);
474 gchar * basename = g_path_get_basename(application);
475
476 gchar * app_info_path = NULL;
477
478 if (g_getenv("HUD_APP_INFO_DIR") != NULL) {
479 app_info_path = g_strdup(g_getenv("HUD_APP_INFO_DIR"));
480 } else {
481 app_info_path = g_build_filename(DATADIR, "indicator-appmenu", "hud", "app-info", NULL);
482 }
483
484 gchar * app_info_filename = g_strdup_printf("%s.hud-app-info", basename);
485 gchar * app_info = g_build_filename(app_info_path, app_info_filename, NULL);
486
487 if (!load_app_info(app_info, self->priv->db)) {
488 if (g_file_test(app_info, G_FILE_TEST_EXISTS)) {
489 g_warning("Unable to load application information for application '%s' at path '%s'", application, app_info);
490 }
491 }
492
493 g_free(app_info);
494 g_free(app_info_filename);
495 g_free(app_info_path);
496 g_free(basename);
497
498 return;
499}
500
501UsageTracker *
502usage_tracker_get_instance (void)
503{
504 static UsageTracker *usage_tracker_instance;
505
506 if (usage_tracker_instance == NULL)
507 usage_tracker_instance = usage_tracker_new ();
508
509 return usage_tracker_instance;
510}
5110
=== removed file 'src/usage-tracker.h'
--- src/usage-tracker.h 2012-02-28 15:22:00 +0000
+++ src/usage-tracker.h 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1/*
2Tracks which menu items get used by users and works to promote those
3higher in the search rankings than others.
4
5Copyright 2011 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef __USAGE_TRACKER_H__
24#define __USAGE_TRACKER_H__
25
26#include <glib-object.h>
27
28G_BEGIN_DECLS
29
30#define USAGE_TRACKER_TYPE (usage_tracker_get_type ())
31#define USAGE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USAGE_TRACKER_TYPE, UsageTracker))
32#define USAGE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USAGE_TRACKER_TYPE, UsageTrackerClass))
33#define IS_USAGE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USAGE_TRACKER_TYPE))
34#define IS_USAGE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USAGE_TRACKER_TYPE))
35#define USAGE_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USAGE_TRACKER_TYPE, UsageTrackerClass))
36
37typedef struct _UsageTracker UsageTracker;
38typedef struct _UsageTrackerClass UsageTrackerClass;
39typedef struct _UsageTrackerPrivate UsageTrackerPrivate;
40
41struct _UsageTrackerClass {
42 GObjectClass parent_class;
43};
44
45struct _UsageTracker {
46 GObject parent;
47
48 UsageTrackerPrivate * priv;
49};
50
51GType usage_tracker_get_type (void);
52UsageTracker * usage_tracker_new (void);
53void usage_tracker_mark_usage (UsageTracker * self, const gchar * application, const gchar * entry);
54guint usage_tracker_get_usage (UsageTracker * self, const gchar * application, const gchar * entry);
55UsageTracker * usage_tracker_get_instance (void);
56
57G_END_DECLS
58
59#endif

Subscribers

People subscribed via source and target branches