From cbf74eee39060328dcd88cde412c34046e46f896 Mon Sep 17 00:00:00 2001 From: Juha Kallioinen Date: Mon, 24 Feb 2014 18:06:33 +0200 Subject: [PATCH] [ssu] separate connman dependency to a plugin library New package ssu-network-proxy-plugin provides ssu-network-proxy, which is required by ssu. Signed-off-by: Juha Kallioinen --- libssunetworkproxy/libssunetworkproxy.pri | 2 ++ libssunetworkproxy/libssunetworkproxy.pro | 12 +++++++ .../libssunetworkproxy_dependencies.pri | 1 + libssunetworkproxy/ssunetworkproxy.cpp | 13 ++++++++ libssunetworkproxy/ssunetworkproxy.h | 31 +++++++++++++++++++ rndssucli/main.cpp | 4 +-- rndssucli/rndssucli.pro | 1 - rndssucli/rndssucli_dependencies.pri | 1 + rpm/ssu.spec | 15 ++++++++- ssu.pro | 4 +-- ssud/main.cpp | 4 +-- ssud/ssud.pro | 3 +- ssud/ssud_dependencies.pri | 1 + ssuurlresolver/main.cpp | 4 +-- ssuurlresolver/ssuurlresolver.pro | 1 - .../ssuurlresolver_dependencies.pri | 1 + 16 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 libssunetworkproxy/libssunetworkproxy.pri create mode 100644 libssunetworkproxy/libssunetworkproxy.pro create mode 100644 libssunetworkproxy/libssunetworkproxy_dependencies.pri create mode 100644 libssunetworkproxy/ssunetworkproxy.cpp create mode 100644 libssunetworkproxy/ssunetworkproxy.h diff --git a/libssunetworkproxy/libssunetworkproxy.pri b/libssunetworkproxy/libssunetworkproxy.pri new file mode 100644 index 0000000..bfcfd2a --- /dev/null +++ b/libssunetworkproxy/libssunetworkproxy.pri @@ -0,0 +1,2 @@ +include(libssunetworkproxy_dependencies.pri) +LIBS *= -ldl diff --git a/libssunetworkproxy/libssunetworkproxy.pro b/libssunetworkproxy/libssunetworkproxy.pro new file mode 100644 index 0000000..d10730c --- /dev/null +++ b/libssunetworkproxy/libssunetworkproxy.pro @@ -0,0 +1,12 @@ +TARGET = ssunetworkproxy +include(../ssulibrary.pri) + +HEADERS = ssunetworkproxy.h + +SOURCES = ssunetworkproxy.cpp + +CONFIG += link_pkgconfig plugin + +QT += network + +PKGCONFIG += connman-qt5 diff --git a/libssunetworkproxy/libssunetworkproxy_dependencies.pri b/libssunetworkproxy/libssunetworkproxy_dependencies.pri new file mode 100644 index 0000000..df6332b --- /dev/null +++ b/libssunetworkproxy/libssunetworkproxy_dependencies.pri @@ -0,0 +1 @@ +# none yet diff --git a/libssunetworkproxy/ssunetworkproxy.cpp b/libssunetworkproxy/ssunetworkproxy.cpp new file mode 100644 index 0000000..11996f2 --- /dev/null +++ b/libssunetworkproxy/ssunetworkproxy.cpp @@ -0,0 +1,13 @@ +/** + * @file ssunetworkproxy.cpp + * @copyright 2014 Jolla Ltd. + * @author Juha Kallioinen + * @date 2014 + */ + +#include + +extern "C" void initialize() +{ + QNetworkProxyFactory::setApplicationProxyFactory(new ConnmanNetworkProxyFactory); +} diff --git a/libssunetworkproxy/ssunetworkproxy.h b/libssunetworkproxy/ssunetworkproxy.h new file mode 100644 index 0000000..1ea923f --- /dev/null +++ b/libssunetworkproxy/ssunetworkproxy.h @@ -0,0 +1,31 @@ +/** + * @file ssunetworkproxy.h + * @copyright 2014 Jolla Ltd. + * @author Juha Kallioinen + * @date 2014 + */ + +#ifndef _LibSsuNetworkProxy_H +#define _LibSsuNetworkProxy_H +#include + +/** + * Set application proxy if the required library is found, otherwise + * do nothing. + */ +inline void set_application_proxy_factory() +{ + void *proxylib = dlopen("libssunetworkproxy.so", RTLD_LAZY); + if (proxylib) { + typedef void (*ssuproxyinit_t)(); + dlerror(); + ssuproxyinit_t proxy_init = (ssuproxyinit_t) dlsym(proxylib, "initialize"); + const char *dlsym_err = dlerror(); + if (!dlsym_err) { + proxy_init(); + } + dlclose(proxylib); + } +} + +#endif diff --git a/rndssucli/main.cpp b/rndssucli/main.cpp index c584e8b..ad045fe 100644 --- a/rndssucli/main.cpp +++ b/rndssucli/main.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "libssunetworkproxy/ssunetworkproxy.h" #include "rndssucli.h" int main(int argc, char** argv){ @@ -24,7 +24,7 @@ int main(int argc, char** argv){ QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app.installTranslator(&qtTranslator); - QNetworkProxyFactory::setApplicationProxyFactory(new ConnmanNetworkProxyFactory); + set_application_proxy_factory(); RndSsuCli mw; QTimer::singleShot(0, &mw, SLOT(run())); diff --git a/rndssucli/rndssucli.pro b/rndssucli/rndssucli.pro index 2bb0bd5..b4db6cd 100644 --- a/rndssucli/rndssucli.pro +++ b/rndssucli/rndssucli.pro @@ -4,7 +4,6 @@ include(rndssucli_dependencies.pri) QT += network dbus CONFIG += link_pkgconfig -PKGCONFIG += connman-qt5 HEADERS = rndssucli.h \ ssuproxy.h diff --git a/rndssucli/rndssucli_dependencies.pri b/rndssucli/rndssucli_dependencies.pri index 48c7cf6..ed2d69a 100644 --- a/rndssucli/rndssucli_dependencies.pri +++ b/rndssucli/rndssucli_dependencies.pri @@ -1 +1,2 @@ include(../libssu/libssu.pri) +include(../libssunetworkproxy/libssunetworkproxy.pri) diff --git a/rpm/ssu.spec b/rpm/ssu.spec index 19c3d84..d302036 100644 --- a/rpm/ssu.spec +++ b/rpm/ssu.spec @@ -23,6 +23,7 @@ Requires(pre): shadow-utils Requires(pre): /usr/bin/groupadd-user Requires(postun): shadow-utils Requires: ssu-vendor-data +Requires: ssu-network-proxy %description %{summary}. @@ -32,7 +33,7 @@ Requires: ssu-vendor-data %{_libdir}/zypp/plugins/urlresolver/* %{_bindir}/rndssu %{_bindir}/ssu -%{_libdir}/*.so.* +%{_libdir}/libssu.so.* %dir %{_sysconfdir}/zypp/credentials.d # ssu itself does not use the package-update triggers, but provides # them for the vendor data packages to use @@ -41,6 +42,18 @@ Requires: ssu-vendor-data %{_datadir}/dbus-1/system-services/*.service %{_sysconfdir}/dbus-1/system.d/*.conf +%package network-proxy-plugin +Summary: Network Proxy support for ssu +Group: System/Base +Provides: ssu-network-proxy + +%description network-proxy-plugin +%{summary}. + +%files network-proxy-plugin +%defattr(-,root,root,-) +%{_libdir}/libssunetworkproxy.so + %package vendor-data-example Summary: Sample vendor configuration data Group: System/Base diff --git a/ssu.pro b/ssu.pro index 7e672e3..1278291 100644 --- a/ssu.pro +++ b/ssu.pro @@ -3,7 +3,7 @@ contains(QT_VERSION, ^4\\.[0-7]\\..*) { } TEMPLATE = subdirs -SUBDIRS = libssu ssud +SUBDIRS = libssu libssunetworkproxy ssud SUBDIRS += rndssucli ssuurlresolver ssuks ssuconfhack { @@ -41,4 +41,4 @@ system(qdbusxml2cpp \ system(qdbusxml2cpp \ -c SsuProxy \ -p rndssucli/ssuproxy.h:rndssucli/ssuproxy.cpp \ - dbus/org.nemo.ssu.xml) \ No newline at end of file + dbus/org.nemo.ssu.xml) diff --git a/ssud/main.cpp b/ssud/main.cpp index e8922e5..2ec828c 100644 --- a/ssud/main.cpp +++ b/ssud/main.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include "libssunetworkproxy/ssunetworkproxy.h" #include "ssud.h" int main(int argc, char** argv){ @@ -23,7 +23,7 @@ int main(int argc, char** argv){ QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app.installTranslator(&qtTranslator); - QNetworkProxyFactory::setApplicationProxyFactory(new ConnmanNetworkProxyFactory); + set_application_proxy_factory(); Ssud ssud; diff --git a/ssud/ssud.pro b/ssud/ssud.pro index 2b75065..74d7b5a 100644 --- a/ssud/ssud.pro +++ b/ssud/ssud.pro @@ -4,7 +4,6 @@ include(ssud_dependencies.pri) QT += network dbus CONFIG += link_pkgconfig -PKGCONFIG += connman-qt5 HEADERS = ssuadaptor.h \ ssud.h @@ -20,4 +19,4 @@ service.path = /usr/share/dbus-1/system-services/ conf.files = ../dbus/$${DBUS_SERVICE_NAME}.conf conf.path = /etc/dbus-1/system.d/ -INSTALLS += service conf \ No newline at end of file +INSTALLS += service conf diff --git a/ssud/ssud_dependencies.pri b/ssud/ssud_dependencies.pri index 48c7cf6..ed2d69a 100644 --- a/ssud/ssud_dependencies.pri +++ b/ssud/ssud_dependencies.pri @@ -1 +1,2 @@ include(../libssu/libssu.pri) +include(../libssunetworkproxy/libssunetworkproxy.pri) diff --git a/ssuurlresolver/main.cpp b/ssuurlresolver/main.cpp index 7ae26d4..fb4a756 100644 --- a/ssuurlresolver/main.cpp +++ b/ssuurlresolver/main.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "libssunetworkproxy/ssunetworkproxy.h" #include "ssuurlresolver.h" int main(int argc, char** argv){ @@ -24,7 +24,7 @@ int main(int argc, char** argv){ QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app.installTranslator(&qtTranslator); - QNetworkProxyFactory::setApplicationProxyFactory(new ConnmanNetworkProxyFactory); + set_application_proxy_factory(); SsuUrlResolver mw; QTimer::singleShot(0, &mw, SLOT(run())); diff --git a/ssuurlresolver/ssuurlresolver.pro b/ssuurlresolver/ssuurlresolver.pro index cef7e43..c6afb4d 100644 --- a/ssuurlresolver/ssuurlresolver.pro +++ b/ssuurlresolver/ssuurlresolver.pro @@ -8,7 +8,6 @@ target.path = /usr/lib/zypp/plugins/urlresolver QT += network CONFIG += link_pkgconfig -PKGCONFIG += connman-qt5 HEADERS = ssuurlresolver.h SOURCES = main.cpp \ diff --git a/ssuurlresolver/ssuurlresolver_dependencies.pri b/ssuurlresolver/ssuurlresolver_dependencies.pri index 48c7cf6..ed2d69a 100644 --- a/ssuurlresolver/ssuurlresolver_dependencies.pri +++ b/ssuurlresolver/ssuurlresolver_dependencies.pri @@ -1 +1,2 @@ include(../libssu/libssu.pri) +include(../libssunetworkproxy/libssunetworkproxy.pri)