Skip to content

Commit

Permalink
Core/Engines: migrate to MonoAddins infrastructure
Browse files Browse the repository at this point in the history
Only for the backend for now.
(TODO: Load frontends with mono-addins too.)
This integration work opens the door for more
add-in management love, such as loading/unloading
capabilities at runtime, installing/updating
add-ins from remote repositories (via Cydin[1]), etc.

(The way to make this build in macOS is similar to
the approach done with log4net[2].)

[1] https://github.com/slluis/cydin
[2] bdbfb26
  • Loading branch information
knocte committed Jan 14, 2021
1 parent d60bb78 commit 0a1e4cd
Show file tree
Hide file tree
Showing 22 changed files with 228 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install:
- sudo apt-get build-dep smuxi > /dev/null
- sudo apt-get install devscripts equivs > /dev/null
- sudo mk-build-deps --install debian/control > /dev/null
- sudo apt-get install mono-devel nunit-console moreutils gtk-sharp2-gapi libgtkspell-dev > /dev/null
- sudo apt-get install mono-devel nunit-console moreutils gtk-sharp2-gapi libgtkspell-dev libmono-addins-cil-dev > /dev/null
- sudo apt-get install libnunit-cil-dev > /dev/null

script:
Expand Down
6 changes: 5 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ fi
AC_SUBST(XBUILD_FLAGS)

# Required Libraries

if test "x$(uname)" != "xDarwin"; then
PKG_CHECK_MODULES(MONO_ADDINS, mono-addins >= 1.0)
AC_SUBST(MONO_ADDINS_LIBS)
AM_CONDITIONAL([BUNDLE_MONO_ADDINS], false)

PKG_CHECK_MODULES([LOG4NET], [log4net])
AM_CONDITIONAL([BUNDLE_LOG4NET], false)
else
AM_CONDITIONAL([BUNDLE_MONO_ADDINS], true)
AM_CONDITIONAL([BUNDLE_LOG4NET], true)
fi

Expand Down
Binary file added lib/Mono.Addins.dll
Binary file not shown.
22 changes: 22 additions & 0 deletions src/Engine-Campfire/Engine-Campfire.addin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Addin
id="smuxi-engine-campfire"
version="1.1"
compatVersion="1.1"
copyright="© 2012 Carlos Martín Nieto. Licensed under the GPL license."
name="Campfire"
category="Engines"
description="Support for Campfire protocol."
author="Carlos Martín Nieto"
url="http://smuxi.im/"
defaultEnabled="true">

<Dependencies>
<!-- not depending on other addin, just the addinRoot -->
<Addin id="smuxi-engine" version="1.1"/>
</Dependencies>

<Extension path="/Smuxi/Server/Engine">
<Engine class="Smuxi.Engine.CampfireProtocolManager"/>
</Extension>
</Addin>
5 changes: 5 additions & 0 deletions src/Engine-Campfire/Engine-Campfire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@
<Name>ServiceStack.Interfaces</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Engine-Campfire.addin.xml">
<LogicalName>Enging-Campfire.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions src/Engine-Campfire/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ SOURCES = \
Protocols/Campfire/CampfireEventStream.cs \
Protocols/Campfire/DTO.cs

RESOURCES = \
Engine-Campfire.addin.xml

REFERENCES = \
System \
System.Web \
Expand All @@ -36,5 +39,5 @@ include $(top_srcdir)/Makefile.include

all: $(ASSEMBLY_TARGET)

$(ASSEMBLY_TARGET) $(ASSEMBLY_TARGET).mdb: $(SOURCES) $(DLL_REFERENCES)
$(CSC) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD)
$(ASSEMBLY_TARGET) $(ASSEMBLY_TARGET).mdb: $(SOURCES) $(DLL_REFERENCES) $(build_resources)
$(CSC) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD) $(build_resources_embed)
22 changes: 22 additions & 0 deletions src/Engine-IRC/Engine-IRC.addin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Addin
id="smuxi-engine-irc"
version="1.1"
compatVersion="1.1"
copyright="© 2005-2015 Mirco Bauer. Licensed under the GPL license."
name="IRC"
category="Engines"
description="Support for IRC protocol."
author="Mirco Bauer"
url="http://smuxi.im/"
defaultEnabled="true">

<Dependencies>
<!-- not depending on other addin, just the addinRoot -->
<Addin id="smuxi-engine" version="1.1"/>
</Dependencies>

<Extension path="/Smuxi/Server/Engine">
<Engine class="Smuxi.Engine.IrcProtocolManager"/>
</Extension>
</Addin>
5 changes: 5 additions & 0 deletions src/Engine-IRC/Engine-IRC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,9 @@
<Reference Include="System.Core" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="Engine-IRC.addin.xml">
<LogicalName>Engine-IRC.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion src/Engine-IRC/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ FILES = \

DATA_FILES =

RESOURCES =
RESOURCES = \
Engine-IRC.addin.xml

EXTRAS = \
smuxi-engine-irc.pc.in
Expand Down
22 changes: 22 additions & 0 deletions src/Engine-JabbR/Engine-JabbR.addin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Addin
id="smuxi-engine-jabbr"
version="1.1"
compatVersion="1.1"
copyright="© 2012-2014 Mirco Bauer. Licensed under the GPL license."
name="IRC"
category="Engines"
description="Support for JabbR protocol."
author="Mirco Bauer"
url="http://smuxi.im/"
defaultEnabled="true">

<Dependencies>
<!-- not depending on other addin, just the addinRoot -->
<Addin id="smuxi-engine" version="1.1"/>
</Dependencies>

<Extension path="/Smuxi/Server/Engine">
<Engine class="Smuxi.Engine.JabbrProtocolManager"/>
</Extension>
</Addin>
5 changes: 5 additions & 0 deletions src/Engine-JabbR/Engine-JabbR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="Engine-JabbR.addin.xml">
<LogicalName>Engine-JabbR.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions src/Engine-JabbR/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ SOURCES = \
JabbrMessageBuilder.cs \
JabbrProtocolManager.cs

RESOURCES = \
Engine-JabbR.addin.xml

REFERENCES = \
System \
System.Web \
Expand All @@ -40,5 +43,5 @@ include $(top_srcdir)/Makefile.include

all: $(ASSEMBLY_TARGET)

$(ASSEMBLY_TARGET) $(ASSEMBLY_TARGET).mdb: $(SOURCES) $(DLL_REFERENCES)
$(CSC) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD)
$(ASSEMBLY_TARGET) $(ASSEMBLY_TARGET).mdb: $(SOURCES) $(DLL_REFERENCES) $(build_resources)
$(CSC) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD) $(build_resources_embed)
22 changes: 22 additions & 0 deletions src/Engine-Twitter/Engine-Twitter.addin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Addin
id="smuxi-engine-twitter"
version="1.1"
compatVersion="1.1"
copyright="© 2009-2015 Mirco Bauer. Licensed under the GPL license."
name="Twitter"
category="Engines"
description="Support for Twitter protocol."
author="Mirco Bauer"
url="http://smuxi.im/"
defaultEnabled="true">

<Dependencies>
<!-- not depending on other addin, just the addinRoot -->
<Addin id="smuxi-engine" version="1.1"/>
</Dependencies>

<Extension path="/Smuxi/Server/Engine">
<Engine class="Smuxi.Engine.TwitterProtocolManager"/>
</Extension>
</Addin>
5 changes: 5 additions & 0 deletions src/Engine-Twitter/Engine-Twitter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="Engine-Twitter.addin.xml">
<LogicalName>Engine-Twitter.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions src/Engine-Twitter/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ SOURCES = \
Protocols/Twitter/TwitterMessageBuilder.cs \
Protocols/Twitter/TwitterSearchStream.cs

RESOURCES = \
Engine-Twitter.addin.xml

REFERENCES = $(LOG4NET_REF_LIBS) \
$(SMARTIRC4NET_LIBS) \
System.Web \
Expand All @@ -44,5 +47,5 @@ include $(top_srcdir)/Makefile.include

all: $(ASSEMBLY_TARGET)

$(ASSEMBLY_TARGET): $(SOURCES) $(DLL_REFERENCES)
$(MCS) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD)
$(ASSEMBLY_TARGET): $(SOURCES) $(DLL_REFERENCES) $(build_resources)
$(MCS) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD) $(build_resources_embed)
23 changes: 23 additions & 0 deletions src/Engine-XMPP/Engine-XMPP.addin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Addin
id="smuxi-engine-xmpp"
version="1.1"
compatVersion="1.1"
copyright="© 2005-2006 Mirco Bauer, © 2011 tuukka, © 2013-2014 Oliver Schneider. Licensed under the GPL license."
name="XMPP"
category="Engines"
description="Support for XMPP and XMPP-based protocols (e.g. Facebook)."
author="Mirco Bauer, Oliver Schneider"
url="http://smuxi.im/"
defaultEnabled="true">

<Dependencies>
<!-- not depending on other addin, just the addinRoot -->
<Addin id="smuxi-engine" version="1.1"/>
</Dependencies>

<Extension path="/Smuxi/Server/Engine">
<Engine class="Smuxi.Engine.XmppProtocolManager"/>
<Engine class="Smuxi.Engine.FacebookProtocolManager"/>
</Extension>
</Addin>
5 changes: 5 additions & 0 deletions src/Engine-XMPP/Engine-XMPP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@
<Reference Include="System.Core" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="Engine-XMPP.addin.xml">
<LogicalName>Engine-XMPP.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions src/Engine-XMPP/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ SOURCES = \
Protocols/Xmpp/XmppProtocolManager.cs \
Config/XmppPersonModel.cs

RESOURCES = \
Engine-XMPP.addin.xml

REFERENCES = \
System \
System.Core \
Expand All @@ -42,5 +45,6 @@ include $(top_srcdir)/Makefile.include

all: $(ASSEMBLY_TARGET)

$(ASSEMBLY_TARGET) $(ASSEMBLY_TARGET).mdb: $(SOURCES) $(DLL_REFERENCES)
$(CSC) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD)
$(ASSEMBLY_TARGET) $(ASSEMBLY_TARGET).mdb: $(SOURCES) $(DLL_REFERENCES) $(build_resources)
$(CSC) $(CSC_FLAGS) $(build_references_ref) -target:library -out:$(ASSEMBLY_TARGET) $(SOURCES_BUILD) $(build_resources_embed)

25 changes: 25 additions & 0 deletions src/Engine/AddinHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Smuxi - Smart MUltipleXed Irc
//
// Copyright (c) 2016 Andrés G. Aragoneses
//
// Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

using Mono.Addins;

[assembly:AddinRoot("smuxi-engine", "1.1")]
[assembly:AddinDescription("This add-in root provides the engine extension point for add-in protocols to hook")]
[assembly:ExtensionPoint("/Smuxi/Server/Engine", NodeName="Engine")]
4 changes: 4 additions & 0 deletions src/Engine/Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="AddinHost.cs" />
<Compile Include="CommandModel.cs" />
<Compile Include="Engine.cs" />
<Compile Include="FrontendManager.cs" />
Expand Down Expand Up @@ -150,6 +151,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Web" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="Mono.Addins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
<Package>mono-addins</Package>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
Expand Down
9 changes: 9 additions & 0 deletions src/Engine/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ SMUXI_COMMON_DLL_SOURCE=../../bin/debug/smuxi-common.dll

endif

if BUNDLE_MONO_ADDINS
MONO_ADDINS_DLL_SOURCE=../../lib/Mono.Addins.dll
MONO_ADDINS_REF_LIBS=-r:$(MONO_ADDINS_DLL_SOURCE)
else
MONO_ADDINS_REF_LIBS=$(MONO_ADDINS_LIBS)
endif

if BUNDLE_LOG4NET
LOG4NET_DLL_SOURCE=../../lib/log4net.dll
LOG4NET_REF_LIBS=-r:$(LOG4NET_DLL_SOURCE)
Expand Down Expand Up @@ -61,6 +68,7 @@ all: $(ASSEMBLY) $(PROGRAMFILES) $(LINUX_PKGCONFIG)
FILES = \
../AssemblyVersion.cs \
AssemblyInfo.cs \
AddinHost.cs \
CertificateValidator.cs \
CommandModel.cs \
Engine.cs \
Expand Down Expand Up @@ -146,6 +154,7 @@ REFERENCES = \
System.Xml \
Mono.Posix \
Mono.Data.Sqlite \
$(MONO_ADDINS_REF_LIBS) \
$(NINI_REF_LIBS) \
$(LOG4NET_REF_LIBS) \
$(DB4O_LIBS) \
Expand Down
Loading

0 comments on commit 0a1e4cd

Please sign in to comment.