Initial plugin system
|
@ -18,9 +18,11 @@ endif()
|
|||
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set (VALA_CFLAGS -Wno-deprecated-declarations -Wno-incompatible-pointer-types -Wno-int-conversion)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
|
||||
set (VALA_CFLAGS -Wno-deprecated-declarations -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-discarded-qualifiers)
|
||||
|
||||
add_subdirectory(gpgme-vala)
|
||||
add_subdirectory(qlite)
|
||||
add_subdirectory(xmpp-vala)
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(libdino)
|
||||
add_subdirectory(main)
|
|
@ -1,12 +0,0 @@
|
|||
using Dino.Entities;
|
||||
using Dino.Ui;
|
||||
|
||||
namespace Dino {
|
||||
|
||||
void main(string[] args) {
|
||||
Notify.init("dino");
|
||||
Gtk.init(ref args);
|
||||
Dino.Ui.Application app = new Dino.Ui.Application();
|
||||
app.run(args);
|
||||
}
|
||||
}
|
|
@ -115,9 +115,11 @@ function(_vala_mkdir_for_file file)
|
|||
endfunction()
|
||||
|
||||
function(vala_precompile output)
|
||||
cmake_parse_arguments(ARGS "" "DIRECTORY;GENERATE_HEADER;GENERATE_VAPI"
|
||||
cmake_parse_arguments(ARGS "FAST_VAPI" "DIRECTORY;GENERATE_HEADER;GENERATE_VAPI"
|
||||
"SOURCES;PACKAGES;OPTIONS;DEFINITIONS;CUSTOM_VAPIS;GRESOURCES" ${ARGN})
|
||||
|
||||
set(ARGS_FAST_VAPI true)
|
||||
|
||||
if(ARGS_DIRECTORY)
|
||||
get_filename_component(DIRECTORY ${ARGS_DIRECTORY} ABSOLUTE)
|
||||
else(ARGS_DIRECTORY)
|
||||
|
@ -159,7 +161,8 @@ function(vala_precompile output)
|
|||
set(vapi_arguments "")
|
||||
if(ARGS_GENERATE_VAPI)
|
||||
list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi")
|
||||
set(vapi_arguments "--vapi=${ARGS_GENERATE_VAPI}.vapi")
|
||||
list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}-internal.vapi")
|
||||
set(vapi_arguments "--vapi=${ARGS_GENERATE_VAPI}.vapi" "--internal-vapi=${ARGS_GENERATE_VAPI}-internal.vapi")
|
||||
|
||||
# Header and internal header is needed to generate internal vapi
|
||||
if (NOT ARGS_GENERATE_HEADER)
|
||||
|
@ -175,6 +178,7 @@ function(vala_precompile output)
|
|||
list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h")
|
||||
endif(ARGS_GENERATE_HEADER)
|
||||
|
||||
if(ARGS_FAST_VAPI)
|
||||
foreach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
|
||||
set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
||||
list(APPEND in_files "${in_file}")
|
||||
|
@ -267,5 +271,39 @@ function(vala_precompile output)
|
|||
"Generating VAPI and headers for linking"
|
||||
)
|
||||
endif()
|
||||
else(ARGS_FAST_VAPI)
|
||||
foreach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
|
||||
set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
||||
list(APPEND in_files "${in_file}")
|
||||
string(REPLACE ".vala" ".c" src ${src})
|
||||
string(REPLACE ".gs" ".c" src ${src})
|
||||
list(APPEND out_files "${DIRECTORY}/${src}")
|
||||
|
||||
_vala_mkdir_for_file("${fast_vapi_file}")
|
||||
endforeach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
|
||||
|
||||
add_custom_command(OUTPUT ${out_files} ${out_extra_files}
|
||||
COMMAND
|
||||
${VALA_EXECUTABLE}
|
||||
ARGS
|
||||
-C
|
||||
${header_arguments}
|
||||
${vapi_arguments}
|
||||
"-b" ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"-d" ${DIRECTORY}
|
||||
${vala_pkg_opts}
|
||||
${vala_define_opts}
|
||||
${gresources_args}
|
||||
${ARGS_OPTIONS}
|
||||
${in_files}
|
||||
${custom_vapi_arguments}
|
||||
DEPENDS
|
||||
${in_files}
|
||||
${ARGS_CUSTOM_VAPIS}
|
||||
${ARGS_GRESOURCES}
|
||||
COMMENT
|
||||
"Generating C code for target ${output}"
|
||||
)
|
||||
endif(ARGS_FAST_VAPI)
|
||||
set(${output} ${out_files} PARENT_SCOPE)
|
||||
endfunction(vala_precompile)
|
||||
|
|
18
configure
vendored
|
@ -15,27 +15,27 @@ then
|
|||
fi
|
||||
|
||||
if [ -x "$(which ninja 2>/dev/null)" ]; then
|
||||
echo "Using Ninja ($(which ninja))"
|
||||
echo "-- Found Ninja: $(which ninja)"
|
||||
cmake_type="Ninja"
|
||||
exec_bin="ninja"
|
||||
elif [ -x "$(which ninja-build 2>/dev/null)" ]; then
|
||||
echo "Using Ninja ($(which ninja-build))"
|
||||
echo "-- Found Ninja: $(which ninja-build)"
|
||||
cmake_type="Ninja"
|
||||
exec_bin="ninja-build"
|
||||
elif [ -x "$(which make 2>/dev/null)" ]; then
|
||||
echo "Using Make ($(which make))"
|
||||
echo "-- Found Make: $(which make)"
|
||||
cmake_type="Unix Makefiles"
|
||||
exec_bin="make"
|
||||
printf "Using Ninja improves build experience, continue with Make? [y/N] "
|
||||
exec_bin="make -j4"
|
||||
echo "-- Using Ninja might improve build experience."
|
||||
cont
|
||||
else
|
||||
echo "No compatible build system (Ninja, Make) found."
|
||||
echo "-!- No compatible build system (Ninja, Make) found."
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ -f ./build ]
|
||||
then
|
||||
echo "./build file exists. ./configure can't continue"
|
||||
echo "-!- ./build file exists. ./configure can't continue"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
@ -43,13 +43,13 @@ if [ -d build ]
|
|||
then
|
||||
if [ ! -f "build/.cmake_type" ]
|
||||
then
|
||||
printf "./build exists but was not created by ./configure script, continue? [y/N] "
|
||||
printf "-!- ./build exists but was not created by ./configure script, continue? [y/N] "
|
||||
cont
|
||||
fi
|
||||
last_type=`cat build/.cmake_type`
|
||||
if [ "$cmake_type" != "$last_type" ]
|
||||
then
|
||||
echo "Using different build system, cleaning build system files"
|
||||
echo "-- Using different build system, cleaning build system files"
|
||||
cd build
|
||||
rm -r CMakeCache.txt CMakeFiles
|
||||
cd ..
|
||||
|
|
|
@ -28,7 +28,7 @@ OPTIONS
|
|||
--thread
|
||||
)
|
||||
|
||||
set(CFLAGS ${GPGME_VALA_CFLAGS} ${GPGME_CFLAGS} -g ${VALA_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set(CFLAGS ${VALA_CFLAGS} ${GPGME_VALA_CFLAGS} ${GPGME_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
add_definitions(${CFLAGS})
|
||||
add_library(gpgme-vala SHARED ${GPGME_VALA_C} src/fix.c)
|
||||
target_link_libraries(gpgme-vala ${GPGME_VALA_LIBRARIES} ${GPGME_LIBRARIES})
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
find_package(Vala REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(GPGME REQUIRED)
|
||||
find_package(LIBUUID REQUIRED)
|
||||
include(${VALA_USE_FILE})
|
||||
include(GlibCompileResourcesSupport)
|
||||
|
||||
set(CLIENT_PACKAGES
|
||||
set(LIBDINO_PACKAGES
|
||||
gee-0.8
|
||||
gio-2.0
|
||||
glib-2.0
|
||||
gtk+-3.0
|
||||
gmodule-2.0
|
||||
libnotify
|
||||
sqlite3
|
||||
)
|
||||
|
||||
pkg_check_modules(CLIENT REQUIRED ${CLIENT_PACKAGES})
|
||||
pkg_check_modules(LIBDINO REQUIRED ${LIBDINO_PACKAGES})
|
||||
|
||||
set(RESOURCE_LIST
|
||||
img/double_tick.svg
|
||||
|
@ -52,8 +51,8 @@ set(RESOURCE_LIST
|
|||
)
|
||||
|
||||
compile_gresources(
|
||||
CLIENT_GRESOURCES_TARGET
|
||||
CLIENT_GRESOURCES_XML
|
||||
LIBDINO_GRESOURCES_TARGET
|
||||
LIBDINO_GRESOURCES_XML
|
||||
TARGET ${CMAKE_BINARY_DIR}/resources/resources.c
|
||||
TYPE EMBED_C
|
||||
RESOURCES ${RESOURCE_LIST}
|
||||
|
@ -61,9 +60,9 @@ compile_gresources(
|
|||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data
|
||||
)
|
||||
|
||||
vala_precompile(CLIENT_VALA_C
|
||||
vala_precompile(LIBDINO_VALA_C
|
||||
SOURCES
|
||||
src/main.vala
|
||||
src/plugin.vala
|
||||
|
||||
src/dbus/login1.vala
|
||||
src/dbus/networkmanager.vala
|
||||
|
@ -124,25 +123,31 @@ SOURCES
|
|||
src/ui/settings_dialog.vala
|
||||
src/ui/unified_window.vala
|
||||
src/ui/util.vala
|
||||
CUSTOM_VAPIS
|
||||
${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi
|
||||
${CMAKE_BINARY_DIR}/qlite/qlite.vapi
|
||||
PACKAGES
|
||||
${CLIENT_PACKAGES}
|
||||
xmpp-vala
|
||||
qlite
|
||||
${LIBDINO_PACKAGES}
|
||||
GENERATE_VAPI
|
||||
dino
|
||||
GENERATE_HEADER
|
||||
dino
|
||||
GRESOURCES
|
||||
${CLIENT_GRESOURCES_XML}
|
||||
${LIBDINO_GRESOURCES_XML}
|
||||
OPTIONS
|
||||
--target-glib=2.38
|
||||
-g
|
||||
--thread
|
||||
--vapidir=${CMAKE_BINARY_DIR}/xmpp-vala
|
||||
--vapidir=${CMAKE_BINARY_DIR}/qlite
|
||||
--vapidir=${CMAKE_SOURCE_DIR}/vapi
|
||||
|
||||
)
|
||||
|
||||
set(CFLAGS ${CLIENT_CFLAGS} -g -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite ${VALA_CFLAGS})
|
||||
set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite)
|
||||
add_definitions(${CFLAGS})
|
||||
add_executable(dino ${CLIENT_VALA_C} ${CLIENT_GRESOURCES_TARGET})
|
||||
add_dependencies(dino xmpp-vala-vapi qlite-vapi)
|
||||
target_link_libraries(dino xmpp-vala qlite ${CLIENT_LIBRARIES} -lm)
|
||||
add_library(libdino SHARED ${LIBDINO_VALA_C} ${LIBDINO_GRESOURCES_TARGET})
|
||||
add_dependencies(libdino xmpp-vala-vapi qlite-vapi)
|
||||
target_link_libraries(libdino xmpp-vala qlite ${LIBDINO_LIBRARIES} -lm)
|
||||
set_target_properties(libdino PROPERTIES PREFIX "")
|
||||
|
||||
add_custom_target(dino-vapi
|
||||
DEPENDS
|
||||
${CMAKE_BINARY_DIR}/libdino/dino.vapi
|
||||
)
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
64
libdino/src/plugin.vala
Normal file
|
@ -0,0 +1,64 @@
|
|||
namespace Dino {
|
||||
|
||||
public errordomain PluginError {
|
||||
NOT_SUPPORTED,
|
||||
UNEXPECTED_TYPE,
|
||||
NO_REGISTRATION_FUNCTION,
|
||||
FAILED
|
||||
}
|
||||
|
||||
public interface PluginIface : Object {
|
||||
public abstract void registered(Dino.Ui.Application app);
|
||||
}
|
||||
|
||||
private class PluginInfo : Object {
|
||||
public Module module;
|
||||
public Type gtype;
|
||||
|
||||
public PluginInfo(Type type, owned Module module) {
|
||||
this.module = (owned) module;
|
||||
this.gtype = type;
|
||||
}
|
||||
}
|
||||
|
||||
public class PluginLoader : Object {
|
||||
[CCode (has_target = false)]
|
||||
private delegate Type RegisterPluginFunction (Module module);
|
||||
|
||||
private PluginIface[] plugins = new PluginIface[0];
|
||||
private PluginInfo[] infos = new PluginInfo[0];
|
||||
|
||||
public PluginIface load(string name, Dino.Ui.Application app) throws PluginError {
|
||||
if (Module.supported () == false) {
|
||||
throw new PluginError.NOT_SUPPORTED ("Plugins are not supported");
|
||||
}
|
||||
|
||||
Module module = Module.open ("plugins/" + name, ModuleFlags.BIND_LAZY);
|
||||
if (module == null) {
|
||||
throw new PluginError.FAILED (Module.error ());
|
||||
}
|
||||
|
||||
void* function;
|
||||
module.symbol ("register_plugin", out function);
|
||||
if (function == null) {
|
||||
throw new PluginError.NO_REGISTRATION_FUNCTION ("register_plugin () not found");
|
||||
}
|
||||
|
||||
RegisterPluginFunction register_plugin = (RegisterPluginFunction) function;
|
||||
Type type = register_plugin (module);
|
||||
if (type.is_a (typeof (PluginIface)) == false) {
|
||||
throw new PluginError.UNEXPECTED_TYPE ("Unexpected type");
|
||||
}
|
||||
|
||||
PluginInfo info = new PluginInfo (type, (owned) module);
|
||||
infos += info;
|
||||
|
||||
PluginIface plugin = (PluginIface) Object.new (type);
|
||||
plugins += plugin;
|
||||
plugin.registered (app);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -28,6 +28,7 @@ public class Dino.Ui.Application : Gtk.Application {
|
|||
ConversationManager.start(stream_interaction, db);
|
||||
ChatInteraction.start(stream_interaction);
|
||||
|
||||
Notify.init("dino");
|
||||
notifications = new Notifications(stream_interaction);
|
||||
notifications.start();
|
||||
|
35
main/CMakeLists.txt
Normal file
|
@ -0,0 +1,35 @@
|
|||
find_package(Vala REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
include(${VALA_USE_FILE})
|
||||
|
||||
set(MAIN_PACKAGES
|
||||
gee-0.8
|
||||
gio-2.0
|
||||
glib-2.0
|
||||
gtk+-3.0
|
||||
gmodule-2.0
|
||||
sqlite3
|
||||
)
|
||||
|
||||
pkg_check_modules(MAIN REQUIRED ${MAIN_PACKAGES})
|
||||
|
||||
vala_precompile(MAIN_VALA_C
|
||||
SOURCES
|
||||
src/main.vala
|
||||
CUSTOM_VAPIS
|
||||
${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi
|
||||
${CMAKE_BINARY_DIR}/qlite/qlite.vapi
|
||||
${CMAKE_BINARY_DIR}/libdino/dino.vapi
|
||||
PACKAGES
|
||||
${MAIN_PACKAGES}
|
||||
OPTIONS
|
||||
--target-glib=2.38
|
||||
-g
|
||||
--thread
|
||||
)
|
||||
|
||||
set(CFLAGS ${VALA_CFLAGS} ${MAIN_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite -I${CMAKE_BINARY_DIR}/libdino)
|
||||
add_definitions(${CFLAGS})
|
||||
add_executable(dino ${MAIN_VALA_C})
|
||||
add_dependencies(dino dino-vapi)
|
||||
target_link_libraries(dino libdino)
|
20
main/src/main.vala
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Dino.Entities;
|
||||
using Dino.Ui;
|
||||
|
||||
namespace Dino {
|
||||
|
||||
void main(string[] args) {
|
||||
Gtk.init(ref args);
|
||||
Dino.Ui.Application app = new Dino.Ui.Application();
|
||||
PluginLoader loader = new PluginLoader();
|
||||
foreach(string plugin in new string[]{}) {
|
||||
try {
|
||||
loader.load(plugin, app);
|
||||
} catch (Dino.PluginError e) {
|
||||
print(@"Error loading plugin $plugin: $(e.message)\n");
|
||||
}
|
||||
}
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ OPTIONS
|
|||
--vapidir=${CMAKE_SOURCE_DIR}/vapi
|
||||
)
|
||||
|
||||
set(CFLAGS ${QLITE_CFLAGS} -g ${VALA_CFLAGS})
|
||||
set(CFLAGS ${VALA_CFLAGS} ${QLITE_CFLAGS})
|
||||
add_definitions(${CFLAGS})
|
||||
add_library(qlite SHARED ${QLITE_VALA_C})
|
||||
target_link_libraries(qlite ${QLITE_LIBRARIES})
|
||||
|
|
|
@ -9,7 +9,7 @@ set(ENGINE_PACKAGES
|
|||
gee-0.8
|
||||
gio-2.0
|
||||
glib-2.0
|
||||
gtk+-3.0
|
||||
gdk-3.0
|
||||
)
|
||||
|
||||
pkg_check_modules(ENGINE REQUIRED ${ENGINE_PACKAGES})
|
||||
|
@ -80,10 +80,10 @@ OPTIONS
|
|||
--vapidir=${CMAKE_SOURCE_DIR}/vapi
|
||||
)
|
||||
|
||||
set(CFLAGS ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -g ${VALA_CFLAGS} -I${CMAKE_BINARY_DIR}/gpgme-vala)
|
||||
set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -I${CMAKE_BINARY_DIR}/gpgme-vala)
|
||||
add_definitions(${CFLAGS})
|
||||
add_library(xmpp-vala SHARED ${ENGINE_VALA_C})
|
||||
add_dependencies(xmpp-vala gpgme-vala gpgme-vapi)
|
||||
add_dependencies(xmpp-vala gpgme-vapi)
|
||||
target_link_libraries(xmpp-vala gpgme-vala ${ENGINE_LIBRARIES} ${GPGME_LIBRARIES} ${LIBUUID_LIBRARIES})
|
||||
|
||||
add_custom_target(xmpp-vala-vapi
|
||||
|
|