[longomatch] Add addins support



commit 02a7298a1a5918b969cc8ff45c147ea1f2b76fd7
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Dec 1 20:07:09 2011 +0100

    Add addins support

 LongoMatch.Addins/AddinsManager.cs                 |   50 ++++++++++++++++++++
 .../ExtensionPoints/IConfigModifier.cs             |   31 ++++++++++++
 .../ExtensionPoints/IExportProject.cs              |   33 +++++++++++++
 LongoMatch.Addins/LongoMatch.Addins.mdp            |   26 ++++++++++
 LongoMatch.Core/LongoMatch.Core.mdp                |    3 +-
 LongoMatch.Services/LongoMatch.Services.mdp        |    7 ++-
 LongoMatch.Services/Services/Core.cs               |    7 ++-
 LongoMatch.mds                                     |    4 ++
 LongoMatch/LongoMatchGtk.mdp                       |    1 +
 LongoMatch/Main.cs                                 |    3 +
 10 files changed, 160 insertions(+), 5 deletions(-)
---
diff --git a/LongoMatch.Addins/AddinsManager.cs b/LongoMatch.Addins/AddinsManager.cs
new file mode 100644
index 0000000..e1b214d
--- /dev/null
+++ b/LongoMatch.Addins/AddinsManager.cs
@@ -0,0 +1,50 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using System.IO;
+using Mono.Addins;
+
+using LongoMatch;
+using LongoMatch.Addins.ExtensionPoints;
+
+[assembly:AddinRoot ("LongoMatch", "1.0")]
+
+namespace LongoMatch.Addins
+{
+	public class AddinsManager
+	{
+		public AddinsManager (string addinsPath)
+		{
+			Log.Information("Initializing addins at path: " + addinsPath);
+			AddinManager.Initialize (addinsPath);
+			AddinManager.Registry.Update();
+		}
+		
+		public void LoadConfigModifierAddins() {
+			foreach (IConfigModifier configModifier in AddinManager.GetExtensionObjects<IConfigModifier> ()) {
+				configModifier.ModifyConfig();
+			}
+		}
+		
+		public void LoadExportProjectAddins() {
+			foreach (IExportProject exportProject in AddinManager.GetExtensionObjects<IExportProject> ()) {
+			}
+		}
+	}
+}
+
diff --git a/LongoMatch.Addins/ExtensionPoints/IConfigModifier.cs b/LongoMatch.Addins/ExtensionPoints/IConfigModifier.cs
new file mode 100644
index 0000000..1b23f86
--- /dev/null
+++ b/LongoMatch.Addins/ExtensionPoints/IConfigModifier.cs
@@ -0,0 +1,31 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using Mono.Addins;
+
+using LongoMatch;
+using LongoMatch.Store;
+
+namespace LongoMatch.Addins.ExtensionPoints
+{
+	[TypeExtensionPoint]
+	public interface IConfigModifier
+	{
+		void ModifyConfig();
+	}
+}
\ No newline at end of file
diff --git a/LongoMatch.Addins/ExtensionPoints/IExportProject.cs b/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
new file mode 100644
index 0000000..6cbc3c7
--- /dev/null
+++ b/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
@@ -0,0 +1,33 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using Mono.Addins;
+
+using LongoMatch.Store;
+using LongoMatch.Interfaces.GUI;
+
+namespace LongoMatch.Addins.ExtensionPoints
+{
+	[TypeExtensionPoint]
+	public interface IExportProject
+	{
+		void AddMenuEntry(IMainWindow mainWindow);
+		void ExportProject(Project project);
+	}
+}
+
diff --git a/LongoMatch.Addins/LongoMatch.Addins.mdp b/LongoMatch.Addins/LongoMatch.Addins.mdp
new file mode 100644
index 0000000..cc693da
--- /dev/null
+++ b/LongoMatch.Addins/LongoMatch.Addins.mdp
@@ -0,0 +1,26 @@
+<Project name="LongoMatch.Addins" fileversion="2.0" DefaultNamespace="LongoMatch.Addins" language="C#" targetFramework="4.0" ctype="DotNetProject">
+  <Configurations active="Release">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="../bin" assembly="LongoMatch.Addins" />
+      <Build debugmode="True" target="Library" />
+      <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+    <Configuration name="Release" ctype="DotNetProjectConfiguration">
+      <Output directory="../bin" assembly="LongoMatch.Addins" />
+      <Build debugmode="False" target="Library" />
+      <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File subtype="Code" buildaction="Compile" name="ExtensionPoints/IExportProject.cs" />
+    <File subtype="Code" buildaction="Compile" name="ExtensionPoints/IConfigModifier.cs" />
+    <File subtype="Code" buildaction="Compile" name="AddinsManager.cs" />
+    <File subtype="Directory" buildaction="Compile" name="." />
+  </Contents>
+  <References>
+    <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+    <ProjectReference type="Project" localcopy="True" refto="LongoMatch.Core" />
+  </References>
+</Project>
\ No newline at end of file
diff --git a/LongoMatch.Core/LongoMatch.Core.mdp b/LongoMatch.Core/LongoMatch.Core.mdp
index 4bddabf..7e8d93e 100644
--- a/LongoMatch.Core/LongoMatch.Core.mdp
+++ b/LongoMatch.Core/LongoMatch.Core.mdp
@@ -97,5 +97,6 @@
     <ProjectReference type="Gac" localcopy="True" refto="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
   </References>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/LongoMatch.Services/LongoMatch.Services.mdp b/LongoMatch.Services/LongoMatch.Services.mdp
index 138449b..77d4f82 100644
--- a/LongoMatch.Services/LongoMatch.Services.mdp
+++ b/LongoMatch.Services/LongoMatch.Services.mdp
@@ -14,7 +14,6 @@
     </Configuration>
   </Configurations>
   <Contents>
-    <File subtype="Directory" buildaction="Compile" name="." />
     <File subtype="Code" buildaction="Compile" name="Services/DataBase.cs" />
     <File subtype="Code" buildaction="Compile" name="Services/TemplatesService.cs" />
     <File subtype="Code" buildaction="Compile" name="Services/RenderingJobsManager.cs" />
@@ -27,11 +26,15 @@
     <File subtype="Directory" buildaction="Compile" name="." />
     <File subtype="Code" buildaction="Compile" name="Services/GameUnitsManager.cs" />
     <File subtype="Directory" buildaction="Compile" name="." />
+    <File subtype="Directory" buildaction="Compile" name="." />
+    <File subtype="Directory" buildaction="Compile" name=".." />
+    <File subtype="Directory" buildaction="Compile" name="Services" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Project" localcopy="True" refto="LongoMatch.Core" />
     <ProjectReference type="Gac" localcopy="True" refto="Db4objects.Db4o, Version=8.0.184.15484, Culture=neutral, PublicKeyToken=6199cd4f203aa8eb" />
+    <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
   </References>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/LongoMatch.Services/Services/Core.cs b/LongoMatch.Services/Services/Core.cs
index d3fd8b0..2efd7a3 100644
--- a/LongoMatch.Services/Services/Core.cs
+++ b/LongoMatch.Services/Services/Core.cs
@@ -18,13 +18,16 @@
 using System;
 using System.IO;
 using Mono.Unix;
+using Mono.Addins;
 
-using LongoMatch.Interfaces.GUI;
-using LongoMatch.Interfaces.Multimedia;
+using LongoMatch;
 using LongoMatch.DB;
 using LongoMatch.Common;
+using LongoMatch.Interfaces.GUI;
+using LongoMatch.Interfaces.Multimedia;
 using LongoMatch.Store;
 
+
 namespace LongoMatch.Services
 {
 	public class Core
diff --git a/LongoMatch.mds b/LongoMatch.mds
index 67a8dc9..68d28fa 100644
--- a/LongoMatch.mds
+++ b/LongoMatch.mds
@@ -25,6 +25,7 @@
       <Entry build="True" name="LongoMatch.Multimedia" configuration="Debug" />
       <Entry build="True" name="LongoMatch.Services" configuration="Debug" />
       <Entry build="True" name="LongoMatch.GUI.Multimedia" configuration="Debug" />
+      <Entry build="True" name="LongoMatch.Addins" configuration="Debug" />
     </Configuration>
     <Configuration name="Release" ctype="CombineConfiguration">
       <Entry build="True" name="LongoMatch.GUI" configuration="Release" />
@@ -34,6 +35,7 @@
       <Entry build="True" name="LongoMatch.Multimedia" configuration="Release" />
       <Entry build="True" name="LongoMatch.Services" configuration="Release" />
       <Entry build="True" name="LongoMatch.GUI.Multimedia" configuration="Release" />
+      <Entry build="True" name="LongoMatch.Addins" configuration="Release" />
     </Configuration>
   </Configurations>
   <StartMode startupentry="LongoMatchGtk" single="True">
@@ -44,6 +46,7 @@
     <Execute type="None" entry="LongoMatch.Multimedia" />
     <Execute type="None" entry="LongoMatch.Services" />
     <Execute type="None" entry="LongoMatch.GUI.Multimedia" />
+    <Execute type="None" entry="LongoMatch.Addins" />
   </StartMode>
   <Entries>
     <Entry filename="LongoMatch.GUI/LongoMatch.GUI.mdp" />
@@ -53,5 +56,6 @@
     <Entry filename="LongoMatch.Multimedia/LongoMatch.Multimedia.mdp" />
     <Entry filename="LongoMatch.Services/LongoMatch.Services.mdp" />
     <Entry filename="LongoMatch.GUI.Multimedia/LongoMatch.GUI.Multimedia.mdp" />
+    <Entry filename="LongoMatch.Addins/LongoMatch.Addins.mdp" />
   </Entries>
 </Combine>
\ No newline at end of file
diff --git a/LongoMatch/LongoMatchGtk.mdp b/LongoMatch/LongoMatchGtk.mdp
index f72b8cc..7ecd637 100644
--- a/LongoMatch/LongoMatchGtk.mdp
+++ b/LongoMatch/LongoMatchGtk.mdp
@@ -30,5 +30,6 @@
     <ProjectReference type="Project" localcopy="True" refto="LongoMatch.Multimedia" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Project" localcopy="True" refto="LongoMatch.Core" />
+    <ProjectReference type="Project" localcopy="True" refto="LongoMatch.Addins" />
   </References>
 </Project>
\ No newline at end of file
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index 172e692..4996721 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -24,6 +24,7 @@ using System.IO;
 using Gtk;
 using Mono.Unix;
 
+using LongoMatch.Addins;
 using LongoMatch.Interfaces.GUI;
 using LongoMatch.Interfaces.Multimedia;
 using LongoMatch.Gui;
@@ -55,6 +56,8 @@ namespace LongoMatch
 
 			//try {
 				Core.Init();
+				AddinsManager manager = new AddinsManager(Path.Combine(Config.HomeDir(), "addins"));
+				manager.LoadConfigModifierAddins();
 			    GUIToolkit guiToolkit = new GUIToolkit();
 			    IMultimediaToolkit multimediaToolkit = new MultimediaFactory();
 				Core.Start(guiToolkit, multimediaToolkit);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]