Merge lp:~mhr3/libzeitgeist/various-fixes into lp:libzeitgeist

Proposed by Michal Hruby
Status: Merged
Merged at revision: 191
Proposed branch: lp:~mhr3/libzeitgeist/various-fixes
Merge into: lp:libzeitgeist
Diff against target: 514 lines (+0/-451)
6 files modified
Makefile.am (+0/-4)
configure.ac (+0/-26)
module/Makefile.am (+0/-28)
module/gapplaunchhandlerzeitgeist.c (+0/-304)
module/gapplaunchhandlerzeitgeist.h (+0/-49)
module/zeitgeist-module.c (+0/-40)
To merge this branch: bzr merge lp:~mhr3/libzeitgeist/various-fixes
Reviewer Review Type Date Requested Status
LibZeitgeist Developers Pending
Review via email: mp+48904@code.launchpad.net

Description of the change

Remove the GIO module, it's Ubuntu specific and its function is now overtaken by datahub.

To post a comment you must log in.
lp:~mhr3/libzeitgeist/various-fixes updated
191. By Mikkel Kamstrup Erlandsen

Merge Michal's branch, lp:~mhr3/libzeitgeist/various-fixes, removing the giomodule. The same functionality has been implemented in lp:zeitgeist-datahub trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2010-08-18 19:51:26 +0000
+++ Makefile.am 2011-02-08 11:56:54 +0000
@@ -5,10 +5,6 @@
5 examples \5 examples \
6 tests6 tests
77
8if ENABLE_GIOMODULE
9SUBDIRS += module
10endif
11
12pkgconfigdir = $(libdir)/pkgconfig8pkgconfigdir = $(libdir)/pkgconfig
13pkgconfig_DATA = zeitgeist-1.0.pc9pkgconfig_DATA = zeitgeist-1.0.pc
1410
1511
=== modified file 'configure.ac'
--- configure.ac 2010-12-17 10:41:52 +0000
+++ configure.ac 2011-02-08 11:56:54 +0000
@@ -67,19 +67,6 @@
67AC_SUBST(MAINTAINER_CFLAGS)67AC_SUBST(MAINTAINER_CFLAGS)
6868
69####################################################################69####################################################################
70# Check whether to build GIO extension point module
71####################################################################
72AC_ARG_ENABLE([module],
73 AS_HELP_STRING([--enable-module=@<:@yes/no@:>@],[build GIO extension point module @<:@default=yes@:>@]),,
74 [enable_module=yes])
75
76if test "x$enable_module" = "xyes"; then
77 AC_DEFINE(ENABLE_GIOMODULE, 1, [build GIO extension point module])
78fi
79
80AM_CONDITIONAL(ENABLE_GIOMODULE, test "$enable_module" = "yes")
81
82####################################################################
83# Check library deps70# Check library deps
84####################################################################71####################################################################
85GLIB_REQUIRED=2.2672GLIB_REQUIRED=2.26
@@ -93,16 +80,6 @@
93AC_SUBST(ZEITGEIST_CFLAGS)80AC_SUBST(ZEITGEIST_CFLAGS)
94AC_SUBST(ZEITGEIST_LIBS)81AC_SUBST(ZEITGEIST_LIBS)
9582
96ZEITGEIST_GIOMODULE_CFLAGS="$GLIB2_CFLAGS $GOBJECT2_CFLAGS $GIO2_CFLAGS $GIO_UNIX2_CFLAGS $ZEITGEIST_CFLAGS"
97ZEITGEIST_GIOMODULE_LIBS="$GLIB2_LIBS $GOBJECT2_LIBS $GIO2_LIBS $GIO_UNIX2_LIBS $ZEITGEIST_LIBS"
98AC_SUBST(ZEITGEIST_GIOMODULE_CFLAGS)
99AC_SUBST(ZEITGEIST_GIOMODULE_LIBS)
100
101# Make giomodulesdir honour 'prefix', so that distcheck works.
102origgiomodulesdir=`pkg-config --variable=giomoduledir gio-2.0`
103giomodulesdir=`echo "$origgiomodulesdir" | sed 's|/usr|${prefix}|'`
104AC_SUBST(giomodulesdir)
105
106GTK_DOC_CHECK(1.0)83GTK_DOC_CHECK(1.0)
10784
108AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)85AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
@@ -120,7 +97,6 @@
120examples/Makefile97examples/Makefile
121src/Makefile98src/Makefile
122tests/Makefile99tests/Makefile
123module/Makefile
124])100])
125101
126AC_MSG_NOTICE([102AC_MSG_NOTICE([
@@ -132,8 +108,6 @@
132108
133 Build API docs : ${enable_gtk_doc}109 Build API docs : ${enable_gtk_doc}
134110
135 Build GIO module : ${enable_module}
136
137 Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS111 Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS
138])112])
139113
140114
=== removed directory 'module'
=== removed file 'module/Makefile.am'
--- module/Makefile.am 2010-11-17 14:48:02 +0000
+++ module/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
1libdir = $(giomodulesdir)
2lib_LTLIBRARIES = libgiozeitgeist.la
3
4
5libgiozeitgeist_la_SOURCES = \
6 gapplaunchhandlerzeitgeist.c \
7 gapplaunchhandlerzeitgeist.h \
8 zeitgeist-module.c \
9 $(NULL)
10
11libgiozeitgeist_la_CFLAGS = \
12 -I$(top_srcdir)/src \
13 -I$(top_builddir)/src \
14 $(ZEITGEIST_GIOMODULE_CFLAGS) \
15 -DG_LOG_DOMAIN=\"ZeitgeistGIOModule\" \
16 $(NULL)
17
18module_flags = -export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload)'
19
20libgiozeitgeist_la_LDFLAGS = \
21 $(module_flags) \
22 $(NULL)
23
24libgiozeitgeist_la_LIBADD = \
25 $(ZEITGEIST_GIOMODULE_LIBS) \
26 $(top_builddir)/src/libzeitgeist-1.0.la \
27 $(NULL)
28
290
=== removed file 'module/gapplaunchhandlerzeitgeist.c'
--- module/gapplaunchhandlerzeitgeist.c 2010-09-16 12:11:26 +0000
+++ module/gapplaunchhandlerzeitgeist.c 1970-01-01 00:00:00 +0000
@@ -1,304 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
18 */
19
20#include <config.h>
21
22#include <glib.h>
23#include <gio/gio.h>
24#include <gio/gdesktopappinfo.h>
25#include <zeitgeist.h>
26
27#include "gapplaunchhandlerzeitgeist.h"
28
29static ZeitgeistLog *log = NULL;
30static gpointer log_w = NULL;
31
32struct _GAppLaunchHandlerZeitgeist {
33 GObject parent;
34
35};
36
37static void launch_handler_iface_init (GDesktopAppInfoLaunchHandlerIface *iface);
38static void g_app_launch_handler_zeitgeist_finalize (GObject *object);
39static void ensure_log (void);
40
41#define _G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) { \
42 const GInterfaceInfo g_implement_interface_info = { \
43 (GInterfaceInitFunc) iface_init, NULL, NULL \
44 }; \
45 g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
46}
47
48G_DEFINE_DYNAMIC_TYPE_EXTENDED (GAppLaunchHandlerZeitgeist, g_app_launch_handler_zeitgeist, G_TYPE_OBJECT, 0,
49 _G_IMPLEMENT_INTERFACE_DYNAMIC (G_TYPE_DESKTOP_APP_INFO_LAUNCH_HANDLER,
50 launch_handler_iface_init))
51
52/* We lazily create the ZeitgeistLog lazily because it creates a dbus
53 * connection, which if set up during the GIOModule registration phase
54 * (ie inside g_app_launch_handler_zeitgeist_register()) might mess up the
55 * gio module initialization process.
56 *
57 * Spurious deadlocks and segfaults have been observed without
58 * lazy setup of the log.
59 */
60static void
61ensure_log (void)
62{
63 if (log_w == NULL)
64 {
65 log = zeitgeist_log_new ();
66 log_w = log;
67 g_object_add_weak_pointer (G_OBJECT (log), &log_w);
68 }
69}
70
71static void
72g_app_launch_handler_zeitgeist_finalize (GObject *object)
73{
74 if (G_OBJECT_CLASS (g_app_launch_handler_zeitgeist_parent_class)->finalize)
75 (*G_OBJECT_CLASS (g_app_launch_handler_zeitgeist_parent_class)->finalize) (object);
76}
77
78static GObject *
79g_app_launch_handler_zeitgeist_constructor (GType type,
80 guint n_construct_properties,
81 GObjectConstructParam *construct_properties)
82{
83 GObject *object;
84 GAppLaunchHandlerZeitgeistClass *klass;
85 GObjectClass *parent_class;
86
87 object = NULL;
88
89 /* Invoke parent constructor. */
90 klass = G_APP_LAUNCH_HANDLER_ZEITGEIST_CLASS (g_type_class_peek (G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST));
91 parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
92 object = parent_class->constructor (type,
93 n_construct_properties,
94 construct_properties);
95
96 return object;
97}
98
99static void
100g_app_launch_handler_zeitgeist_init (GAppLaunchHandlerZeitgeist *lookup)
101{
102}
103
104static void
105g_app_launch_handler_zeitgeist_class_finalize (GAppLaunchHandlerZeitgeistClass *klass)
106{
107}
108
109
110static void
111g_app_launch_handler_zeitgeist_class_init (GAppLaunchHandlerZeitgeistClass *klass)
112{
113 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
114
115 gobject_class->constructor = g_app_launch_handler_zeitgeist_constructor;
116 gobject_class->finalize = g_app_launch_handler_zeitgeist_finalize;
117}
118
119/*
120static void
121on_subject_info_ready (GFile *file,
122 GAsyncResult *res,
123 ZeitgeistEvent *ev)
124{
125 ZeitgeistSubject *su;
126 GError *error;
127 GFileInfo *info;
128 GFile *parent_file;
129 gchar *uri, *parent_uri;
130 const gchar *display_name, *filesystem, *mimetype;
131
132 uri = g_file_get_uri (file);
133
134 error = NULL;
135 info = g_file_query_info_finish (file, res, &error);
136 if (error != NULL)
137 {
138 // On anything but a file-not-found we complain in the log
139 if (error->code != G_IO_ERROR_NOT_FOUND)
140 g_warning ("Error querying file info for '%s': %s",
141 uri, error->message);
142
143 g_free (uri);
144 g_object_unref (ev);
145 g_error_free (error);
146 return;
147 }
148
149 display_name = g_file_info_get_attribute_string (info,
150 G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
151 filesystem = g_file_info_get_attribute_string (info,
152 G_FILE_ATTRIBUTE_ID_FILESYSTEM);
153 mimetype = g_file_info_get_attribute_string (info,
154 G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
155
156 parent_file = g_file_get_parent (file);
157 parent_uri = g_file_get_uri (parent_file);
158
159 // If we couldn't query the filesystem for the subject assume it was a
160 // residing online somwhere
161 filesystem = filesystem != NULL ? filesystem : "net";
162
163 su = zeitgeist_subject_new_full (uri,
164 zeitgeist_interpretation_for_mimetype (mimetype),
165 zeitgeist_manifestation_for_uri (uri),
166 mimetype,
167 parent_uri,
168 display_name,
169 filesystem);
170 zeitgeist_event_add_subject (ev, su);
171
172 // FIXME: Right now we actually insert one event for each subject.
173 // We should rather collect all subject data (async) and
174 // insert one event with all the subjects
175 zeitgeist_log_insert_events_no_reply (log, ev, NULL);
176
177 g_free (uri);
178 g_free (parent_uri);
179 g_object_unref (parent_file);
180 g_object_unref (info);
181}
182*/
183
184/* Create an application://app.desktop URI. Caller must g_free() the result
185 * if it's != NULL */
186static gchar*
187get_application_uri (GDesktopAppInfo *appinfo)
188{
189 gchar *app_id = NULL;
190
191 app_id = g_strdup (g_app_info_get_id (G_APP_INFO (appinfo)));
192
193 if (app_id != NULL)
194 {
195 app_id = g_strconcat ("application://", app_id, NULL);
196 }
197 else if (g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (appinfo)))
198 {
199 const gchar *path = g_desktop_app_info_get_filename (
200 G_DESKTOP_APP_INFO (appinfo));
201 gchar *basename = g_path_get_basename (path);
202 app_id = g_strconcat ("application://", basename, NULL);
203 g_free (basename);
204 }
205
206 return app_id;
207}
208
209/* Idle handler for logging the app launch event. We do this in an
210 * idle call to make sure it's done in the mainloop in order to be
211 * thread safe */
212static gboolean
213log_event (ZeitgeistEvent *event)
214{
215 ensure_log ();
216
217 g_return_val_if_fail (ZEITGEIST_IS_EVENT (event), FALSE);
218 g_return_val_if_fail (ZEITGEIST_IS_LOG (log), FALSE);
219
220 /* Send the event to Zeitgeist */
221 zeitgeist_log_insert_events_no_reply (log, event, NULL);
222
223 return FALSE;
224}
225
226static void
227on_launched (GDesktopAppInfoLaunchHandler *launch_handler,
228 GDesktopAppInfo *app_info,
229 GList *uris,
230 GAppLaunchContext *launch_ctx,
231 gint pid)
232{
233 ZeitgeistEvent *ev;
234 ZeitgeistSubject *su;
235 GFile *file;
236 gchar *subject_uri, *actor, *prgname;
237
238 g_return_if_fail (G_IS_DESKTOP_APP_INFO (app_info));
239
240 /* Don't log stuff about apps not shown in user menus */
241 if (! g_app_info_should_show (G_APP_INFO (app_info)))
242 return;
243
244 ev = zeitgeist_event_new ();
245 su = zeitgeist_subject_new ();
246
247 subject_uri = get_application_uri (app_info);
248
249 if (subject_uri == NULL)
250 {
251 /* We where unable to figure out the launched app... */
252 g_object_unref (ev);
253 g_object_unref (su);
254 return;
255 }
256
257 /* Set event metadata */
258 prgname = g_get_prgname ();
259 zeitgeist_event_set_interpretation (ev, ZEITGEIST_ZG_ACCESS_EVENT);
260 zeitgeist_event_set_manifestation (ev, ZEITGEIST_ZG_USER_ACTIVITY);
261 actor = prgname ? g_strdup_printf ("application://%s.desktop", prgname) :
262 g_strdup ("");
263 zeitgeist_event_set_actor (ev, actor);
264 g_free (actor);
265
266 zeitgeist_event_add_subject (ev, su);
267
268 zeitgeist_subject_set_uri (su, subject_uri);
269 zeitgeist_subject_set_interpretation (su, ZEITGEIST_NFO_SOFTWARE);
270 zeitgeist_subject_set_manifestation (su, ZEITGEIST_NFO_SOFTWARE_ITEM);
271 zeitgeist_subject_set_mimetype (su, "application/x-desktop");
272 zeitgeist_subject_set_text (su, g_app_info_get_display_name (
273 G_APP_INFO (app_info)));
274 g_free (subject_uri);
275 // FIXME: subject origin and storage?
276
277 /* Do all DBus interactions in an idle handler to make sure
278 * we are thread safe. The floating ref on ev swallowed by idle
279 * handler log_event() */
280 g_idle_add ((GSourceFunc) log_event, ev);
281}
282
283static void
284launch_handler_iface_init (GDesktopAppInfoLaunchHandlerIface *iface)
285{
286 iface->on_launched = on_launched;
287}
288
289void
290g_app_launch_handler_zeitgeist_register (GIOModule *module)
291{
292 g_app_launch_handler_zeitgeist_register_type (G_TYPE_MODULE (module));
293 g_io_extension_point_implement (G_DESKTOP_APP_INFO_LAUNCH_HANDLER_EXTENSION_POINT_NAME,
294 G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST,
295 "zeitgeist",
296 10);
297}
298
299void
300g_app_launch_handler_zeitgeist_unregister (GIOModule *module)
301{
302 if (log_w != NULL)
303 g_object_unref (log);
304}
3050
=== removed file 'module/gapplaunchhandlerzeitgeist.h'
--- module/gapplaunchhandlerzeitgeist.h 2010-08-18 19:51:26 +0000
+++ module/gapplaunchhandlerzeitgeist.h 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
18 */
19
20#ifndef __G_APP_LAUNCH_HANDLER_ZEITGEIST_H__
21#define __G_APP_LAUNCH_HANDLER_ZEITGEIST_H__
22
23#include <glib-object.h>
24#include <gio/gio.h>
25#include <gio/gdesktopappinfo.h>
26
27
28G_BEGIN_DECLS
29
30#define G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST (g_app_launch_handler_zeitgeist_get_type ())
31#define G_APP_LAUNCH_HANDLER_ZEITGEIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST, GAppLaunchHandlerZeitgeist))
32#define G_APP_LAUNCH_HANDLER_ZEITGEIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST, GAppLaunchHandlerZeitgeistClass))
33#define G_IS_APP_LAUNCH_HANDLER_ZEITGEIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST))
34#define G_IS_APP_LAUNCH_HANDLER_ZEITGEIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_APP_LAUNCH_HANDLER_ZEITGEIST))
35
36typedef struct _GAppLaunchHandlerZeitgeist GAppLaunchHandlerZeitgeist;
37typedef struct _GAppLaunchHandlerZeitgeistClass GAppLaunchHandlerZeitgeistClass;
38
39struct _GAppLaunchHandlerZeitgeistClass {
40 GObjectClass parent_class;
41};
42
43GType g_app_launch_handler_zeitgeist_get_type (void) G_GNUC_CONST;
44void g_app_launch_handler_zeitgeist_register (GIOModule *module);
45void g_app_launch_handler_zeitgeist_unregister (GIOModule *module);
46
47G_END_DECLS
48
49#endif /* __G_APP_LAUNCH_HANDLER_ZEITGEIST_H__ */
500
=== removed file 'module/zeitgeist-module.c'
--- module/zeitgeist-module.c 2010-08-19 11:57:08 +0000
+++ module/zeitgeist-module.c 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * version 3.0 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License version 3.0 for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library. If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
18 */
19
20#include <config.h>
21
22#include <glib.h>
23#include <gmodule.h>
24#include <gio/gio.h>
25#include <zeitgeist.h>
26
27#include "gapplaunchhandlerzeitgeist.h"
28
29void
30g_io_module_load (GIOModule *module)
31{
32 g_app_launch_handler_zeitgeist_register (module);
33}
34
35void
36g_io_module_unload (GIOModule *module)
37{
38 g_app_launch_handler_zeitgeist_unregister (module);
39}
40

Subscribers

People subscribed via source and target branches