2
using System.Collections.Generic;
5
using System.Threading;
6
using System.ComponentModel;
8
namespace Zeitgeist.Datamodel
10
[Interface("org.gnome.zeitgeist.Monitor")]
11
internal interface IMonitor
13
void NotifyInsert(TimeRange range, RawEvent[] events);
15
void NotifyDelete(TimeRange range, UInt32[] evendIds);
18
internal class RawMonitor : IMonitor
20
public RawMonitor(string monitorPath)
22
ObjectPath objPath = new ObjectPath (monitorPath);
23
Bus.Session.Register (objPath, this);
25
loop = new MainLoop();
26
worker = new BackgroundWorker();
28
worker.DoWork += delegate(object sender, DoWorkEventArgs e) {
32
worker.RunWorkerAsync();
35
public void NotifyInsert(TimeRange range, RawEvent[] events)
37
List<Event> eventList = ZsUtils.FromRawEventList(events);
40
Inserted(range, eventList);
43
public void NotifyDelete(TimeRange range, UInt32[] evendIds)
45
List<UInt32> eventIdList = new List<UInt32>(evendIds);
48
Deleted(range, eventIdList);
51
public event NotifyInsertHandler Inserted;
53
public event NotifyDeleteHandler Deleted;
55
private BackgroundWorker worker;
57
private MainLoop loop;
61
/// DBus interface for monitoring the Zeitgeist log for certain types of events.
62
/// When using the Python bindings monitors are normally instantiated indirectly by calling ZeitgeistClient.install_monitor
65
/// It is important to understand that the Monitor instance lives on the client side, and expose a
66
/// DBus service there, and the Zeitgeist engine calls back to the monitor when matching events are registered.
71
/// Create a new instance of Monitor which can be used for notifying the client that some event has been
72
/// inserted or deleted which matches the event template
74
/// <param name="monitorPath">
75
/// The DBus path over which the bus is activated <see cref="System.String"/>
77
public Monitor(string monitorPath)
79
_monitor = new RawMonitor( monitorPath);
81
_monitor.Inserted += delegate(TimeRange event_range, List<Event> events) {
83
Inserted(event_range, events);
85
_monitor.Deleted += delegate(TimeRange event_range, List<uint> eventIds) {
87
Deleted(event_range, eventIds);
92
/// The event which is fired in the case of an event is inserted which matches the Event Templates
94
public event NotifyInsertHandler Inserted;
97
/// The event which is fired in the case of an event is deleted which matches the Event Templates
99
public event NotifyDeleteHandler Deleted;
101
private RawMonitor _monitor;