Merge lp:~laszlok/zeitgeist-datasources/trunk into lp:zeitgeist-datasources/0.8

Proposed by Laszlo Pandy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~laszlok/zeitgeist-datasources/trunk
Merge into: lp:zeitgeist-datasources/0.8
Diff against target: 308 lines (+264/-0)
6 files modified
gedit/zeitgeist_plugin.py (+1/-0)
rhythmbox/__init__.py (+1/-0)
tomboy/Zeitgeist.addin.xml (+21/-0)
tomboy/Zeitgeist.cs (+200/-0)
tomboy/Zeitgeist.mdp (+28/-0)
tomboy/install.sh (+13/-0)
To merge this branch: bzr merge lp:~laszlok/zeitgeist-datasources/trunk
Reviewer Review Type Date Requested Status
Seif Lotfy Pending
Review via email: mp+18533@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Seif Lotfy (seif) wrote :

only works with trunk for now. But still stable :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'gedit/zeitgeist_plugin.py'
--- gedit/zeitgeist_plugin.py 2010-02-02 01:57:56 +0000
+++ gedit/zeitgeist_plugin.py 2010-02-03 16:27:14 +0000
@@ -3,6 +3,7 @@
3# Zeitgeist3# Zeitgeist
4#4#
5# Copyright © 2009 Seif Lotfy <seif@lotfy.com>5# Copyright © 2009 Seif Lotfy <seif@lotfy.com>
6# Copyright © 2010 Laszlo Pandy <laszlok2@gmail.com>
6#7#
7# This program is free software: you can redistribute it and/or modify8# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by9# it under the terms of the GNU Lesser General Public License as published by
910
=== modified file 'rhythmbox/__init__.py'
--- rhythmbox/__init__.py 2010-01-30 18:44:53 +0000
+++ rhythmbox/__init__.py 2010-02-03 16:27:14 +0000
@@ -3,6 +3,7 @@
3# Zeitgeist3# Zeitgeist
4#4#
5# Copyright © 2009 Markus Korn <thekorn@gmx.de>5# Copyright © 2009 Markus Korn <thekorn@gmx.de>
6# Copyright © 2010 Laszlo Pandy <laszlok2@gmail.com>
6#7#
7# This program is free software: you can redistribute it and/or modify8# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by9# it under the terms of the GNU Lesser General Public License as published by
910
=== added directory 'tomboy'
=== added file 'tomboy/Zeitgeist.addin.xml'
--- tomboy/Zeitgeist.addin.xml 1970-01-01 00:00:00 +0000
+++ tomboy/Zeitgeist.addin.xml 2010-02-03 16:27:14 +0000
@@ -0,0 +1,21 @@
1<Addin id="Zeitgeist"
2 namespace="Tomboy"
3 name="Zeitgeist Integration"
4 author="Tomboy Project"
5 description="Logs usage data to Zeitgeist."
6 category="Tools"
7 defaultEnabled="true"
8 version="0.1">
9
10 <Runtime>
11 <Import assembly="Zeitgeist.dll" />
12 </Runtime>
13
14 <Dependencies>
15 <Addin id="Tomboy" version="1.1.2" />
16 </Dependencies>
17
18 <Extension path="/Tomboy/ApplicationAddins">
19 <ApplicationAddin type="Tomboy.Zeitgeist.ZeitgeistAddin" />
20 </Extension>
21</Addin>
0\ No newline at end of file22\ No newline at end of file
123
=== added file 'tomboy/Zeitgeist.cs'
--- tomboy/Zeitgeist.cs 1970-01-01 00:00:00 +0000
+++ tomboy/Zeitgeist.cs 2010-02-03 16:27:14 +0000
@@ -0,0 +1,200 @@
1
2using System;
3using System.Collections.Generic;
4using Tomboy;
5using NDesk.DBus;
6using Gtk;
7using GLib;
8using Mono.Unix.Native;
9
10namespace Tomboy.Zeitgeist
11{
12 class NoteHandler
13 {
14 private static List<string> handled_notes = new List<string>();
15 private Note note;
16
17 public NoteHandler(Note note) {
18 if (handled_notes.Contains(note.Id) == false) {
19 this.note = note;
20 note.Opened += HandleNoteOpened;
21 if (note.HasWindow) {
22 HandleNoteOpened();
23 }
24 }
25 }
26
27 void HandleNoteOpened (object sender, EventArgs e) {
28 HandleNoteOpened();
29 }
30 void HandleNoteOpened() {
31 note.Window.Hidden += HandleNoteWindowHidden;
32 note.Window.Shown += HandleNoteWindowShown;
33 note.Renamed += HandleNoteRenamed;
34 if (note.Window.Visible) {
35 HandleNoteWindowShown();
36 }
37 }
38
39 void HandleNoteRenamed (Note sender, string old_title)
40 {
41 Console.WriteLine("Zg: Renamed: " + note.Title);
42 ZeitgeistDbus.SendToZeitgeist(note, ZeitgeistDbus.EventInterpretation.ModifyEvent);
43 }
44
45 void HandleNoteWindowShown (object sender, EventArgs e) {
46 HandleNoteWindowShown();
47 }
48 void HandleNoteWindowShown ()
49 {
50 Console.WriteLine("Zg: Note window opened: " + note.Title);
51 ZeitgeistDbus.SendToZeitgeist(note, ZeitgeistDbus.EventInterpretation.OpenEvent);
52 }
53
54 void HandleNoteWindowHidden (object sender, EventArgs e)
55 {
56 Console.WriteLine("Zg: Note window closed: " + note.Title);
57 ZeitgeistDbus.SendToZeitgeist(note, ZeitgeistDbus.EventInterpretation.CloseEvent);
58 }
59 }
60
61 class ZeitgeistDbus
62 {
63 private static ILogger zeitgeist_proxy =
64 Bus.Session.GetObject<ILogger>("org.gnome.zeitgeist.Engine",
65 new ObjectPath("/org/gnome/zeitgeist/log/activity"));
66
67 public enum EventInterpretation {
68 OpenEvent,
69 CloseEvent,
70 CreateEvent,
71 ModifyEvent,
72 }
73
74 private static string GetEventInterpetation(EventInterpretation e) {
75 switch(e) {
76 case EventInterpretation.OpenEvent:
77 return "http://zeitgeist-project.com/schema/1.0/core#OpenEvent";
78 case EventInterpretation.CloseEvent:
79 return "http://zeitgeist-project.com/schema/1.0/core#CloseEvent";
80 case EventInterpretation.CreateEvent:
81 return "http://zeitgeist-project.com/schema/1.0/core#CreateEvent";
82 case EventInterpretation.ModifyEvent:
83 return "http://zeitgeist-project.com/schema/1.0/core#ModifyEvent";
84 default:
85 return null;
86 }
87 }
88
89 public static void SendToZeitgeist(Note note, EventInterpretation ev_interp) {
90 if (zeitgeist_proxy == null) {
91 Console.WriteLine("Zg: cannot connect to zeitgeist, dbus proxy is null");
92 return;
93 }
94
95 string ev_interp_string = GetEventInterpetation(ev_interp);
96 if (ev_interp_string == null) {
97 Console.WriteLine("Zg: unknown interpretation type: " + ev_interp.ToString());
98 return;
99 }
100
101 Timeval t;
102 Syscall.gettimeofday(out t);
103 long millis_now = (t.tv_sec * 1000) + (t.tv_usec / 1000);
104
105 Event e = new Event();
106 e.metadata = new string[5];
107 e.metadata[0] = ""; //id (filled in by Zeitgeist)
108 e.metadata[1] = millis_now.ToString();
109 e.metadata[2] = ev_interp_string;
110 e.metadata[3] = "http://zeitgeist-project.com/schema/1.0/core#UserActivity";
111 e.metadata[4] = "application://tomboy.desktop";
112
113 string[] subject = new string[7];
114 subject[0] = note.Uri;
115 subject[1] = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/#Document";
116 subject[2] = "http://www.semanticdesktop.org/ontologies/nfo/#FileDataObject";
117 subject[3] = ""; //origin
118 subject[4] = "application/x-tomboy"; //mimetype
119 subject[5] = note.Title;
120 subject[6] = ""; //storage id
121
122 e.subjects = new string[][] { subject };
123 e.payload = new byte[0];
124
125 GLib.Idle.Add(delegate() {
126 SendEvent(e);
127 return false;
128 });
129 }
130
131 private static void SendEvent(Event e) {
132 int[] inserted;
133 try {
134 inserted = zeitgeist_proxy.InsertEvents(new Event[] { e });
135 } catch (Exception ex) {
136 Console.WriteLine("Zg: insertion failed: " + ex.Message);
137 return;
138 }
139
140 if (inserted.Length > 0) {
141 Console.WriteLine("Zg: Inserted event: " + inserted[0]);
142 }
143 else {
144 Console.WriteLine("Zg: Insertion failed");
145 }
146 return;
147 }
148 }
149
150 [NDesk.DBus.Interface ("org.gnome.zeitgeist.Log")]
151 interface ILogger {
152 int[] InsertEvents(Event[] events);
153 }
154
155 struct Event {
156 public string[] metadata;
157 public string[][] subjects;
158 public byte[] payload;
159 }
160
161 public class ZeitgeistAddin : ApplicationAddin
162 {
163 private bool _init = false;
164 public override bool Initialized {
165 get { return _init; }
166 }
167
168 public override
169 void Initialize() {
170 Console.WriteLine("Zg: init new");
171 init_handlers();
172 _init = true;
173 }
174
175 public override
176 void Shutdown() {
177 Console.WriteLine("Zg: shutdown");
178 }
179
180 void HandleNoteAdded(object sender, Note new_note) {
181 Console.WriteLine("Zg: Note added: " + new_note.Title);
182 Console.WriteLine("\t" + new_note.Uri);
183
184 new NoteHandler(new_note);
185 ZeitgeistDbus.SendToZeitgeist(new_note, ZeitgeistDbus.EventInterpretation.CreateEvent);
186 }
187
188 public void init_handlers() {
189 foreach (Note note in Tomboy.DefaultNoteManager.Notes) {
190 new NoteHandler(note);
191 }
192
193 Tomboy.DefaultNoteManager.NoteAdded -= HandleNoteAdded;
194 Tomboy.DefaultNoteManager.NoteAdded += HandleNoteAdded;
195 }
196 }
197
198
199
200}
0201
=== added file 'tomboy/Zeitgeist.mdp'
--- tomboy/Zeitgeist.mdp 1970-01-01 00:00:00 +0000
+++ tomboy/Zeitgeist.mdp 2010-02-03 16:27:14 +0000
@@ -0,0 +1,28 @@
1<Project name="Zeitgeist" fileversion="2.0" DefaultNamespace="Zeitgeist" language="C#" targetFramework="2.0" ctype="DotNetProject">
2 <Configurations active="Debug">
3 <Configuration name="Debug" ctype="DotNetProjectConfiguration">
4 <Output directory="bin/Debug" assembly="Zeitgeist" />
5 <Build debugmode="True" target="Library" />
6 <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
7 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
8 </Configuration>
9 <Configuration name="Release" ctype="DotNetProjectConfiguration">
10 <Output directory="bin/Release" assembly="Zeitgeist" />
11 <Build debugmode="False" target="Library" />
12 <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
13 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
14 </Configuration>
15 </Configurations>
16 <Contents>
17 <File subtype="Code" buildaction="Compile" name="Zeitgeist.cs" />
18 <File subtype="Code" buildaction="EmbedAsResource" name="Zeitgeist.addin.xml" />
19 </Contents>
20 <References>
21 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
22 <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
23 <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
24 <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
25 <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
26 <ProjectReference type="Assembly" localcopy="True" specificVersion="False" refto="../../tomboy/Tomboy/Tomboy.exe" />
27 </References>
28</Project>
0\ No newline at end of file29\ No newline at end of file
130
=== added file 'tomboy/install.sh'
--- tomboy/install.sh 1970-01-01 00:00:00 +0000
+++ tomboy/install.sh 2010-02-03 16:27:14 +0000
@@ -0,0 +1,13 @@
1#!/bin/sh
2
3mkdir -p ~/.config/tomboy/addins/
4
5# Please install monodevelop to get mdtool.
6# Please edit Zeitgeist.mdp and change the local path of Tomboy.exe
7# to the correct one for your environment (so it can link to the
8# correct version of Tomboy).
9mdtool build Zeitgeist.mdp
10
11cp bin/Debug/Zeitgeist.dll ~/.config/tomboy/addins/Zeitgeist.dll
12
13

Subscribers

People subscribed via source and target branches