summaryrefslogtreecommitdiff
path: root/tomboy
diff options
context:
space:
mode:
authorManish Sinha <manishsinha@ubuntu.com>2011-04-27 00:08:12 +0530
committerManish Sinha <manishsinha@ubuntu.com>2011-04-27 00:08:12 +0530
commit4fd2287916b0c2790aa0684b41c6160d2f1c71e6 (patch)
treed79f3b9426241401113c8049cc70aabbc24336a3 /tomboy
parent6aade94fa6358f881cfb75122a1f08b370e64852 (diff)
Fixed the Tomboy dataprovider to not connect and then disconnect to the SessionBus every time a single event is pushed. Keep it connected and push only when needed
Diffstat (limited to 'tomboy')
-rw-r--r--tomboy/NoteHandler.cs11
-rw-r--r--tomboy/Zeitgeist.cs12
-rw-r--r--tomboy/ZeitgeistAddin.cs12
-rw-r--r--tomboy/ZeitgeistDataprovider.csproj52
4 files changed, 24 insertions, 63 deletions
diff --git a/tomboy/NoteHandler.cs b/tomboy/NoteHandler.cs
index 5e44a10..afe842f 100644
--- a/tomboy/NoteHandler.cs
+++ b/tomboy/NoteHandler.cs
@@ -6,13 +6,14 @@ namespace Tomboy.Zeitgeist
{
public class NoteHandler
{
- public NoteHandler(Note note)
+ public NoteHandler(Note note, ZeitgeistHandler handler)
{
// Check if the Note has already been processes.
// Whent he note is being processed, event handlers are attached to
if (handledNotes.Contains(note) == false)
{
this._note = note;
+ this._handler = handler;
note.Opened += HandleNoteOpened;
if (note.HasWindow)
@@ -41,7 +42,7 @@ namespace Tomboy.Zeitgeist
void HandleNoteRenamed (Note sender, string old_title)
{
Console.WriteLine("Zg#: Renamed: " + this._note.Title);
- ZeitgeistHandler.SendEvent(sender, Interpretation.Instance.EventInterpretation.ModifyEvent);
+ this._handler.SendEvent(sender, Interpretation.Instance.EventInterpretation.ModifyEvent);
}
void HandleNoteWindowShown (object sender, EventArgs e)
@@ -52,18 +53,20 @@ namespace Tomboy.Zeitgeist
void HandleNoteWindowShown ()
{
Console.WriteLine("Zg#: Note window opened: " + this._note.Title);
- ZeitgeistHandler.SendEvent(this._note, Interpretation.Instance.EventInterpretation.AccessEvent);
+ this._handler.SendEvent(this._note, Interpretation.Instance.EventInterpretation.AccessEvent);
}
void HandleNoteWindowHidden (object sender, EventArgs e)
{
Console.WriteLine("Zg#: Note window closed: " + this._note.Title);
- ZeitgeistHandler.SendEvent(this._note, Interpretation.Instance.EventInterpretation.LeaveEvent);
+ this._handler.SendEvent(this._note, Interpretation.Instance.EventInterpretation.LeaveEvent);
}
private Note _note;
private static List<Note> handledNotes = new List<Note>();
+
+ private ZeitgeistHandler _handler;
}
}
diff --git a/tomboy/Zeitgeist.cs b/tomboy/Zeitgeist.cs
index eee7a50..e76b0da 100644
--- a/tomboy/Zeitgeist.cs
+++ b/tomboy/Zeitgeist.cs
@@ -8,7 +8,14 @@ namespace Tomboy.Zeitgeist
{
public class ZeitgeistHandler
{
- public static bool SendEvent(Note note, NameUri eventInterpretation)
+ public ZeitgeistHandler()
+ {
+ client = new LogClient();
+ }
+
+ private LogClient client;
+
+ public bool SendEvent(Note note, NameUri eventInterpretation)
{
NameUri eventManifestation = Manifestation.Instance.EventManifestation.UserActivity;
@@ -40,9 +47,8 @@ namespace Tomboy.Zeitgeist
}
}
- private static void SendEvent(List<Event> e)
+ private void SendEvent(List<Event> e)
{
- LogClient client = new LogClient();
client.InsertEvents(e);
}
}
diff --git a/tomboy/ZeitgeistAddin.cs b/tomboy/ZeitgeistAddin.cs
index 64c290d..117a3ca 100644
--- a/tomboy/ZeitgeistAddin.cs
+++ b/tomboy/ZeitgeistAddin.cs
@@ -14,7 +14,9 @@ namespace Tomboy.Zeitgeist
notesList = new List<NoteHandler>();
dsReg = new DataSourceClient();
+ handler = new ZeitgeistHandler();
}
+
#region Overridden methods
@@ -66,7 +68,7 @@ namespace Tomboy.Zeitgeist
foreach (Note note in Tomboy.DefaultNoteManager.Notes)
{
- notesList.Add(new NoteHandler(note));
+ notesList.Add(new NoteHandler(note, handler));
}
Tomboy.DefaultNoteManager.NoteAdded -= HandleNoteAdded;
@@ -81,9 +83,9 @@ namespace Tomboy.Zeitgeist
Console.WriteLine("Zg#: Note added: " + new_note.Title);
Console.WriteLine("\t" + new_note.Uri);
- notesList.Add(new NoteHandler(new_note));
+ notesList.Add(new NoteHandler(new_note, handler));
- ZeitgeistHandler.SendEvent(new_note, Interpretation.Instance.EventInterpretation.CreateEvent);
+ handler.SendEvent(new_note, Interpretation.Instance.EventInterpretation.CreateEvent);
}
void HandleNoteDeleted(object sender, Note new_note)
@@ -91,7 +93,7 @@ namespace Tomboy.Zeitgeist
Console.WriteLine("Zg#: Note deleted: " + new_note.Title);
Console.WriteLine("\t" + new_note.Uri);
- ZeitgeistHandler.SendEvent(new_note, Interpretation.Instance.EventInterpretation.DeleteEvent);
+ handler.SendEvent(new_note, Interpretation.Instance.EventInterpretation.DeleteEvent);
}
List<NoteHandler> notesList;
@@ -100,6 +102,8 @@ namespace Tomboy.Zeitgeist
private DataSourceClient dsReg;
+ private ZeitgeistHandler handler;
+
#region Public Constants
public const string TomboyUri = "application://tomboy.desktop";
diff --git a/tomboy/ZeitgeistDataprovider.csproj b/tomboy/ZeitgeistDataprovider.csproj
deleted file mode 100644
index b4eee9e..0000000
--- a/tomboy/ZeitgeistDataprovider.csproj
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{7F5F22BD-EF5D-4A73-AD3A-BEFF422E5CD0}</ProjectGuid>
- <OutputType>Library</OutputType>
- <RootNamespace>ZeitgeistDataProvider</RootNamespace>
- <AssemblyName>ZeitgeistDataProvider</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="zeitgeist-sharp, Version=0.1.0.1, Culture=neutral, PublicKeyToken=e3e10a585a87d40c">
- <Package>zeitgeist-sharp</Package>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="ZeitgeistDataprovider.addin.xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="PushEvents.cs" />
- <Compile Include="AssemblyInfo.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <ProjectReference Include="..\..\..\Tomboy.csproj">
- <Project>{315DBB30-1461-4A41-A23F-A888D84E1EA0}</Project>
- <Name>Tomboy</Name>
- </ProjectReference>
- </ItemGroup>
-</Project>