Skip to content

Commit

Permalink
Merge pull request #28 from kaltsi/proxy-plugin
Browse files Browse the repository at this point in the history
[ssu] separate connman dependency to a plugin library
  • Loading branch information
kaltsi committed Mar 3, 2014
2 parents a90d96e + cbf74ee commit 053ec4f
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 13 deletions.
2 changes: 2 additions & 0 deletions libssunetworkproxy/libssunetworkproxy.pri
@@ -0,0 +1,2 @@
include(libssunetworkproxy_dependencies.pri)
LIBS *= -ldl
12 changes: 12 additions & 0 deletions 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
1 change: 1 addition & 0 deletions libssunetworkproxy/libssunetworkproxy_dependencies.pri
@@ -0,0 +1 @@
# none yet
13 changes: 13 additions & 0 deletions libssunetworkproxy/ssunetworkproxy.cpp
@@ -0,0 +1,13 @@
/**
* @file ssunetworkproxy.cpp
* @copyright 2014 Jolla Ltd.
* @author Juha Kallioinen <juha.kallioinen@jolla.com>
* @date 2014
*/

#include <connman-qt5/connmannetworkproxyfactory.h>

extern "C" void initialize()
{
QNetworkProxyFactory::setApplicationProxyFactory(new ConnmanNetworkProxyFactory);
}
31 changes: 31 additions & 0 deletions libssunetworkproxy/ssunetworkproxy.h
@@ -0,0 +1,31 @@
/**
* @file ssunetworkproxy.h
* @copyright 2014 Jolla Ltd.
* @author Juha Kallioinen <juha.kallioinen@jolla.com>
* @date 2014
*/

#ifndef _LibSsuNetworkProxy_H
#define _LibSsuNetworkProxy_H
#include <dlfcn.h>

/**
* 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
4 changes: 2 additions & 2 deletions rndssucli/main.cpp
Expand Up @@ -10,7 +10,7 @@
#include <QLocale>
#include <QLibraryInfo>
#include <QTimer>
#include <connman-qt5/connmannetworkproxyfactory.h>
#include "libssunetworkproxy/ssunetworkproxy.h"
#include "rndssucli.h"

int main(int argc, char** argv){
Expand All @@ -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()));
Expand Down
1 change: 0 additions & 1 deletion rndssucli/rndssucli.pro
Expand Up @@ -4,7 +4,6 @@ include(rndssucli_dependencies.pri)

QT += network dbus
CONFIG += link_pkgconfig
PKGCONFIG += connman-qt5

HEADERS = rndssucli.h \
ssuproxy.h
Expand Down
1 change: 1 addition & 0 deletions rndssucli/rndssucli_dependencies.pri
@@ -1 +1,2 @@
include(../libssu/libssu.pri)
include(../libssunetworkproxy/libssunetworkproxy.pri)
15 changes: 14 additions & 1 deletion rpm/ssu.spec
Expand Up @@ -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}.
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ssu.pro
Expand Up @@ -3,7 +3,7 @@ contains(QT_VERSION, ^4\\.[0-7]\\..*) {
}

TEMPLATE = subdirs
SUBDIRS = libssu ssud
SUBDIRS = libssu libssunetworkproxy ssud
SUBDIRS += rndssucli ssuurlresolver ssuks

ssuconfhack {
Expand Down Expand Up @@ -41,4 +41,4 @@ system(qdbusxml2cpp \
system(qdbusxml2cpp \
-c SsuProxy \
-p rndssucli/ssuproxy.h:rndssucli/ssuproxy.cpp \
dbus/org.nemo.ssu.xml)
dbus/org.nemo.ssu.xml)
4 changes: 2 additions & 2 deletions ssud/main.cpp
Expand Up @@ -9,7 +9,7 @@
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include <connman-qt5/connmannetworkproxyfactory.h>
#include "libssunetworkproxy/ssunetworkproxy.h"
#include "ssud.h"

int main(int argc, char** argv){
Expand All @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions ssud/ssud.pro
Expand Up @@ -4,7 +4,6 @@ include(ssud_dependencies.pri)

QT += network dbus
CONFIG += link_pkgconfig
PKGCONFIG += connman-qt5

HEADERS = ssuadaptor.h \
ssud.h
Expand All @@ -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
INSTALLS += service conf
1 change: 1 addition & 0 deletions ssud/ssud_dependencies.pri
@@ -1 +1,2 @@
include(../libssu/libssu.pri)
include(../libssunetworkproxy/libssunetworkproxy.pri)
4 changes: 2 additions & 2 deletions ssuurlresolver/main.cpp
Expand Up @@ -10,7 +10,7 @@
#include <QLocale>
#include <QLibraryInfo>
#include <QTimer>
#include <connman-qt5/connmannetworkproxyfactory.h>
#include "libssunetworkproxy/ssunetworkproxy.h"
#include "ssuurlresolver.h"

int main(int argc, char** argv){
Expand All @@ -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()));
Expand Down
1 change: 0 additions & 1 deletion ssuurlresolver/ssuurlresolver.pro
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions ssuurlresolver/ssuurlresolver_dependencies.pri
@@ -1 +1,2 @@
include(../libssu/libssu.pri)
include(../libssunetworkproxy/libssunetworkproxy.pri)

0 comments on commit 053ec4f

Please sign in to comment.