Merge ~khurshid-alam/ubuntu/+source/rhythmbox:master into ~ubuntu-desktop/ubuntu/+source/rhythmbox:ubuntu/master

Proposed by Khurshid Alam
Status: Needs review
Proposed branch: ~khurshid-alam/ubuntu/+source/rhythmbox:master
Merge into: ~ubuntu-desktop/ubuntu/+source/rhythmbox:ubuntu/master
Diff against target: 238 lines (+198/-0)
4 files modified
debian/control (+3/-0)
debian/control.in (+3/-0)
debian/patches/series (+1/-0)
debian/patches/zeitgeist-Use-zeitgeist-via-Gobject-introspection.patch (+191/-0)
Reviewer Review Type Date Requested Status
Jeremy Bícha Needs Fixing
Review via email: mp+362491@code.launchpad.net

Commit message

Port zeitgeist plugin to Python3

Zeitgeist already provides python bindings. Convert them to python3 and use them in rbzeitgeist plugin. That way we can avoid using gir bindings and various manual mappings from zeitgeist interpretation to string. Fixes LP: #1813813

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

I know I am not a reviewer ...

From a quick look it seems like a good conversion.

Given that no one uses this plugin other than Unity wouldn't this be a good opportunity to split the plugin into its own package? This would align more to the current Debian rhythmbox package that no longer ships zeitgeist and reduce the overhead of ubuntu specific patches.

Revision history for this message
Khurshid Alam (khurshid-alam) wrote :

@fossfreedom

Perhaps so. But that means finding a repo, work on makefile etc which will take more time. I would appreciate some help regarding this.

Meanwhile this can go into disco and perhaps @jbicha can merge it back on debian.

Revision history for this message
Khurshid Alam (khurshid-alam) wrote :

@fossfreedom Also synapse used to use it. Though I don't know if they still uses but their zeitgeist plugin should still work as the there hasn't been any API change for zeitgeist in recent years.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

Debian might accept our rhythmbox-plugin-zeitgeist package once we get the plugin working.

I would normally expect something like this to be forwarded to https://gitlab.gnome.org/GNOME/rhythmbox/merge_requests

Are you aware of this comment from the zeitgeist Debian changelog?
https://tracker.debian.org/news/939461/accepted-zeitgeist-101-02-source-amd64-all-into-unstable/

  "Drop python3-zeitgeist package as the binding is not compatible with
  python3, for python3, GIR binding should be used instead. Reintroduce the
  python2 binding for now as we still have one rdependency"

Maybe those extra files you added should be shipped by the zeitgeist package instead?

Maybe Ricotz has some time to help review what you're trying to do here.

Revision history for this message
Khurshid Alam (khurshid-alam) wrote :

@jbicha

Ah. Right. It has already been ported. See https://gitlab.gnome.org/GNOME/rhythmbox/merge_requests/18/

Perhaps you could cherry pick the merge into debian and then it can re-sync into Ubuntu ?

Force pushed with author's commit.

And it's working. I checked.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

Khurshid, have you ever used git-buildpackage's patch-queue feature (gbp pq)?

https://wiki.ubuntu.com/DesktopTeam/git#Pick_some_upstream_commits
https://manpages.debian.org/unstable/gbp-pq

Specifically, we don't edit upstream directly, but we use debian/patches/ so gbp pq helps create and modify those patches.

review: Needs Fixing
Revision history for this message
Khurshid Alam (khurshid-alam) wrote :

Never used gbp-pq, but trying now.

cceffdc... by Khurshid Alam

 Zeigeist-plugin: Cherry-pick fix for upstream merge

Revision history for this message
Khurshid Alam (khurshid-alam) wrote :

I simply added the patch with gbp pq and modify debian/control. I left updating changelog, because I never do that for other upstream merge.

Unmerged commits

cceffdc... by Khurshid Alam

 Zeigeist-plugin: Cherry-pick fix for upstream merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/control b/debian/control
2index 5de2fda..8e6fd7f 100644
3--- a/debian/control
4+++ b/debian/control
5@@ -187,8 +187,11 @@ Depends: ${misc:Depends},
6 ${shlibs:Depends},
7 rhythmbox (>= ${gnome:Version}),
8 rhythmbox (<< ${gnome:NextVersion}),
9+ gir1.2-rb-3.0 (= ${binary:Version}),
10 gir1.2-glib-2.0,
11 gir1.2-peas-1.0,
12+ gir1.2-zeitgeist-2.0,
13+ python3-gi,
14 zeitgeist-core
15 Description: zeitgeist plugin for rhythmbox music player
16 Rhythmbox is a very easy to use music playing and management program
17diff --git a/debian/control.in b/debian/control.in
18index 049e836..e66c5e4 100644
19--- a/debian/control.in
20+++ b/debian/control.in
21@@ -183,8 +183,11 @@ Depends: ${misc:Depends},
22 ${shlibs:Depends},
23 rhythmbox (>= ${gnome:Version}),
24 rhythmbox (<< ${gnome:NextVersion}),
25+ gir1.2-rb-3.0 (= ${binary:Version}),
26 gir1.2-glib-2.0,
27 gir1.2-peas-1.0,
28+ gir1.2-zeitgeist-2.0,
29+ python3-gi,
30 zeitgeist-core
31 Description: zeitgeist plugin for rhythmbox music player
32 Rhythmbox is a very easy to use music playing and management program
33diff --git a/debian/patches/series b/debian/patches/series
34index febc85f..f95255e 100644
35--- a/debian/patches/series
36+++ b/debian/patches/series
37@@ -8,3 +8,4 @@ multiarch_fallback.patch
38 make-shuffle-repeat-proper-toggle-actions.patch
39 restore-traditional-menubar.patch
40 0002-grilo-container-max-tracks.patch
41+zeitgeist-Use-zeitgeist-via-Gobject-introspection.patch
42diff --git a/debian/patches/zeitgeist-Use-zeitgeist-via-Gobject-introspection.patch b/debian/patches/zeitgeist-Use-zeitgeist-via-Gobject-introspection.patch
43new file mode 100644
44index 0000000..f7b2dc6
45--- /dev/null
46+++ b/debian/patches/zeitgeist-Use-zeitgeist-via-Gobject-introspection.patch
47@@ -0,0 +1,191 @@
48+From: joerg eichhorn <je@sys-mail.net>
49+Date: Sat, 10 Nov 2018 16:42:58 +0100
50+Subject: zeitgeist: Use zeitgeist via Gobject introspection
51+
52+Fixes #1340
53+Fixes https://bugs.launchpad.net/ubuntu/+source/rhythmbox/+bug/1313914
54+Fixes https://bugzilla.gnome.org/show_bug.cgi?id=707527
55+
56+From 33bd55de358325ff775cf903371949ca26198d41 Mon Sep 17 00:00:00 2001
57+From: vrishab <gnome.vrb@gmail.com>
58+Date: Sun, 27 Nov 2016 18:29:33 +0530
59+Subject: [PATCH] zeitgeist: Use zeitgeist via Gobject introspection
60+
61+(cherry picked from commit efcb4653a13a723b5b99fb5e387f60d5110ae840)
62+---
63+ plugins/rbzeitgeist/rbzeitgeist.plugin.in | 2 +-
64+ plugins/rbzeitgeist/rbzeitgeist.py | 95 ++++++++++++++++++++-----------
65+ 2 files changed, 63 insertions(+), 34 deletions(-)
66+
67+diff --git a/plugins/rbzeitgeist/rbzeitgeist.plugin.in b/plugins/rbzeitgeist/rbzeitgeist.plugin.in
68+index b699ee7..3d362bb 100644
69+--- a/plugins/rbzeitgeist/rbzeitgeist.plugin.in
70++++ b/plugins/rbzeitgeist/rbzeitgeist.plugin.in
71+@@ -7,4 +7,4 @@ _Name=Zeitgeist
72+ _Description=Inform Zeitgeist about your activity
73+ Authors=Markus Korn <thekorn@gmx.de>
74+ Copyright=Copyright © 2009 Markus Korn
75+-Website=http://www.zeitgeist-project.com
76++Website=http://www.rhythmbox.org/
77+diff --git a/plugins/rbzeitgeist/rbzeitgeist.py b/plugins/rbzeitgeist/rbzeitgeist.py
78+index b04a082..6bba195 100644
79+--- a/plugins/rbzeitgeist/rbzeitgeist.py
80++++ b/plugins/rbzeitgeist/rbzeitgeist.py
81+@@ -26,20 +26,23 @@
82+ # along with this program; if not, write to the Free Software
83+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
84+
85+-import time
86++import gi
87+ import rb
88++import time
89+
90+-from gi.repository import GObject, Gio, GLib, Peas
91+-from gi.repository import RB
92++gi.require_version('Peas', '1.0')
93++gi.require_version('RB', '3.0')
94++gi.require_version('Zeitgeist', '2.0')
95+
96+-from zeitgeist.client import ZeitgeistClient
97+-from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
98++from gi.repository import GObject, Gio, GLib, Peas, Zeitgeist
99++from gi.repository import RB
100+
101+ try:
102+- IFACE = ZeitgeistClient()
103++ logger = Zeitgeist.Log.new()
104++
105+ except RuntimeError as e:
106+ print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" % e)
107+- IFACE = None
108++ logger = None
109+
110+ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
111+ __gtype_name__ = 'ZeitgeistPlugin'
112+@@ -50,7 +53,8 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
113+
114+ def do_activate(self):
115+ print("Loading Zeitgeist plugin...")
116+- if IFACE is not None:
117++
118++ if logger is not None:
119+ shell = self.object
120+ shell_player = shell.props.shell_player
121+ self.__psc_id = shell_player.connect("playing-song-changed", self.playing_song_changed)
122+@@ -61,9 +65,28 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
123+ self.__manual_switch = True
124+ self.__current_song = None
125+
126+- if IFACE.get_version() >= [0, 3, 2, 999]:
127+- IFACE.register_data_source("org.gnome.Rhythmbox,dataprovider", "Rhythmbox", "Play and organize your music collection",
128+- [Event.new_for_values(actor="application://rhythmbox.desktop")])
129++ event = Zeitgeist.Event.new()
130++ event.set_property("interpretation", "Source Registration")
131++ event.set_property("manifestation", Zeitgeist.USER_ACTIVITY)
132++ event.set_property("actor", "application://rhythmbox.desktop")
133++
134++ datasource = Zeitgeist.DataSource.new()
135++ datasource.set_unique_id("org.gnome.Rhythmbox3,dataprovider")
136++ datasource.set_name("Rhythmbox")
137++ datasource.set_description("Play and organize your music collection")
138++ datasource.set_event_templates([event,])
139++ datasource.set_enabled(True)
140++ datasource.set_timestamp(int(time.time()*1000))
141++
142++ # Register Rhythmbox as a data source with Zeitgeist
143++ # engine.
144++ registry = Zeitgeist.DataSourceRegistry.new()
145++ registry.register_data_source(datasource)
146++
147++ # Save references as register_data_source is async.
148++ self.event = event
149++ self.datasource = datasource
150++ self.registry = registry
151+
152+ @staticmethod
153+ def get_song_info(db, entry):
154+@@ -85,10 +108,10 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
155+
156+ def playing_song_changed(self, shell, entry):
157+ if self.__current_song is not None:
158+- self.send_to_zeitgeist_async(self.__current_song, Interpretation.LEAVE_EVENT)
159++ self.send_to_zeitgeist_async(self.__current_song, Zeitgeist.LEAVE_EVENT)
160+
161+ if entry is not None:
162+- self.send_to_zeitgeist_async(entry, Interpretation.ACCESS_EVENT)
163++ self.send_to_zeitgeist_async(entry, Zeitgeist.ACCESS_EVENT)
164+
165+ self.__current_song = entry
166+ GLib.idle_add(self.reset_manual_switch)
167+@@ -111,15 +134,16 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
168+ """
169+ shell = self.object
170+ db = shell.props.db
171++
172+ GLib.idle_add(self.send_to_zeitgeist, db, entry, event_type)
173+
174+ def send_to_zeitgeist(self, db, entry, event_type):
175+ song = self.get_song_info(db, entry)
176+
177+ if self.__manual_switch:
178+- manifest = Manifestation.USER_ACTIVITY
179++ manifest = Zeitgeist.USER_ACTIVITY
180+ else:
181+- manifest = Manifestation.SCHEDULED_ACTIVITY
182++ manifest = Zeitgeist.SCHEDULED_ACTIVITY
183+
184+ def file_info_complete(obj, res, user_data):
185+ try:
186+@@ -129,29 +153,34 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
187+
188+ uri_mimetype = fi.get_content_type()
189+
190+- subject = Subject.new_for_values(
191+- uri=song["location"],
192+- interpretation=unicode(Interpretation.AUDIO),
193+- manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
194+- origin=song["location"].rpartition("/")[0],
195+- mimetype=uri_mimetype,
196+- text=" - ".join([song["title"], song["artist"], song["album"]])
197+- )
198+- event = Event.new_for_values(
199+- timestamp=int(time.time()*1000),
200+- interpretation=unicode(event_type),
201+- manifestation=unicode(manifest),
202+- actor="application://rhythmbox.desktop",
203+- subjects=[subject,]
204+- )
205+- IFACE.insert_event(event)
206++ subject = Zeitgeist.Subject.new()
207++ subject.set_property("uri", song["location"])
208++ subject.set_property("interpretation", str(Zeitgeist.AUDIO))
209++ subject.set_property("manifestation", str(Zeitgeist.FILE_DATA_OBJECT))
210++ subject.set_property("origin", song["location"].rpartition("/")[0])
211++ subject.set_property("mimetype", uri_mimetype)
212++ subject.set_property("text", " - ".join([song["title"], song["artist"], song["album"]]))
213++
214++ event = Zeitgeist.Event.new()
215++ event.set_property("timestamp", int(time.time()*1000))
216++ event.set_property("interpretation", str(event_type))
217++ event.set_property("manifestation", str(manifest))
218++ event.set_property("actor", "application://rhythmbox.desktop")
219++ event.add_subject(subject)
220++
221++ logger.insert_event(event)
222+
223+ f = Gio.file_new_for_uri(song["location"])
224+- f.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_DEFAULT, None, file_info_complete, None)
225++ f.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
226++ Gio.FileQueryInfoFlags.NONE,
227++ GLib.PRIORITY_DEFAULT,
228++ None,
229++ file_info_complete,
230++ None)
231+
232+ def do_deactivate(self):
233+ print("Deactivating Zeitgeist plugin...")
234+- if IFACE is not None:
235++ if logger is not None:
236+ shell = self.object
237+ shell_player = shell.props.shell_player
238+ shell_player.disconnect(self.__psc_id)

Subscribers

People subscribed via source and target branches

to all changes: