./ 0000755 0000041 0000041 00000000000 13062464640 011250 5 ustar www-data www-data ./CMakeLists.txt 0000644 0000041 0000041 00000003534 13062464640 014015 0 ustar www-data www-data project(libqtdbusmock CXX)
cmake_minimum_required(VERSION 2.8.9)
set(API_VERSION 1)
set(ABI_VERSION 1)
set(GETTEXT_PACKAGE libqtdbusmock)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
find_package(PkgConfig REQUIRED)
find_package(Qt5Core REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS})
find_package(Qt5DBus COMPONENTS Qt5DBusMacros REQUIRED)
include_directories(${Qt5DBus_INCLUDE_DIRS})
find_package(Qt5Test REQUIRED)
include_directories(${Qt5Test_INCLUDE_DIRS})
pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1 REQUIRED)
include_directories(${QTDBUSTEST_INCLUDE_DIRS})
pkg_check_modules(NM REQUIRED NetworkManager REQUIRED)
include_directories(${NM_INCLUDE_DIRS})
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(DATA_DIR "${CMAKE_SOURCE_DIR}/data")
set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
set(SOURCE_BINARY_DIR "${CMAKE_BINARY_DIR}/src")
include_directories(${SOURCE_DIR})
include_directories(${SOURCE_BINARY_DIR})
include(GNUInstallDirs)
# Workaround for libexecdir on debian
if (EXISTS "/etc/debian_version")
set(CMAKE_INSTALL_LIBEXECDIR ${CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}")
endif()
set(LOCALE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/locale")
add_definitions(
-std=c++11
-fno-permissive
-pedantic
-Wall
-Wextra
)
configure_file(
"${SOURCE_DIR}/libqtdbusmock/config.h.in"
"${SOURCE_BINARY_DIR}/libqtdbusmock/config.h"
)
add_subdirectory("src")
add_subdirectory("data")
add_subdirectory("templates")
enable_testing()
add_subdirectory(tests)
ADD_CUSTOM_TARGET(
check
${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure
)
find_package(CoverageReport)
enable_coverage_report(
TARGETS
qtdbusmock
unit-tests
FILTER
${CMAKE_SOURCE_DIR}/tests/*
${CMAKE_BINARY_DIR}/*
TESTS
unit-tests
)
./COPYING 0000644 0000041 0000041 00000016727 13062464635 012324 0 ustar www-data www-data GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
./src/ 0000755 0000041 0000041 00000000000 13062464635 012043 5 ustar www-data www-data ./src/CMakeLists.txt 0000644 0000041 0000041 00000000132 13062464635 014577 0 ustar www-data www-data include(GenerateExportHeader)
add_compiler_export_flags()
add_subdirectory(libqtdbusmock) ./src/libqtdbusmock/ 0000755 0000041 0000041 00000000000 13062464640 014702 5 ustar www-data www-data ./src/libqtdbusmock/CMakeLists.txt 0000644 0000041 0000041 00000011617 13062464635 017454 0 ustar www-data www-data
set(
QTDBUSMOCK_SRC
DBusMock.cpp
Method.cpp
MethodCall.cpp
NamedMethodCall.cpp
)
set(
QTDBUSMOCK_PUBLIC_HEADERS
"${CMAKE_CURRENT_BINARY_DIR}/config.h"
DBusMock.h
DeclareMetatypes.h
ExportInterfaces.h
Method.h
MethodCall.h
MockInterfaceClasses.h
NamedMethodCall.h
"${CMAKE_CURRENT_BINARY_DIR}/MockInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/PropertiesInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/NetworkManagerMockInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/NotificationDaemonMockInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/OfonoMockInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/OfonoModemInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/OfonoConnectionManagerInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/OfonoSimManagerInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/OfonoNetworkRegistrationInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/URfkillInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/URfkillDeviceInterface.h"
"${CMAKE_CURRENT_BINARY_DIR}/URfkillKillswitchInterface.h"
)
set_source_files_properties(
"${DATA_DIR}/org.freedesktop.DBus.Mock.xml"
PROPERTIES
NO_NAMESPACE YES
INCLUDE "libqtdbusmock/MockInterfaceClasses.h"
)
set_source_files_properties(
"${DATA_DIR}/org.freedesktop.DBus.Properties.xml"
PROPERTIES
NO_NAMESPACE YES
INCLUDE "libqtdbusmock/ExportInterfaces.h"
)
set_source_files_properties(
"${DATA_DIR}/nm-manager-mock.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME NetworkManagerMockInterface
INCLUDE "libqtdbusmock/ExportInterfaces.h"
)
set_source_files_properties(
"${DATA_DIR}/notification-daemon-mock.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME NotificationDaemonMockInterface
)
set_source_files_properties(
"${DATA_DIR}/ofono-mock.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME OfonoMockInterface
)
set_source_files_properties(
"${DATA_DIR}/ofono-modem-mock.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME OfonoModemInterface
)
set_source_files_properties(
"${DATA_DIR}/ofono-simmanager.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME OfonoSimManagerInterface
)
set_source_files_properties(
"${DATA_DIR}/ofono-connectionmanager.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME OfonoConnectionManagerInterface
)
set_source_files_properties(
"${DATA_DIR}/ofono-networkregistration.xml"
PROPERTIES
NO_NAMESPACE YES
CLASSNAME OfonoNetworkRegistrationInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/org.freedesktop.DBus.Mock.xml"
MockInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/org.freedesktop.DBus.Properties.xml"
PropertiesInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/nm-manager-mock.xml"
NetworkManagerMockInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/notification-daemon-mock.xml"
NotificationDaemonMockInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/ofono-mock.xml"
OfonoMockInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/ofono-modem-mock.xml"
OfonoModemInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/ofono-connectionmanager.xml"
OfonoConnectionManagerInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/ofono-simmanager.xml"
OfonoSimManagerInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/ofono-networkregistration.xml"
OfonoNetworkRegistrationInterface
)
set_source_files_properties(
"${DATA_DIR}/org.freedesktop.URfkill.xml"
PROPERTIES
NO_NAMESPACE YES
)
set_source_files_properties(
"${DATA_DIR}/org.freedesktop.URfkill.Device.xml"
PROPERTIES
NO_NAMESPACE YES
)
set_source_files_properties(
"${DATA_DIR}/org.freedesktop.URfkill.Killswitch.xml"
PROPERTIES
NO_NAMESPACE YES
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/org.freedesktop.URfkill.xml"
URfkillInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/org.freedesktop.URfkill.Device.xml"
URfkillDeviceInterface
)
qt5_add_dbus_interface(
QTDBUSMOCK_SRC
"${DATA_DIR}/org.freedesktop.URfkill.Killswitch.xml"
URfkillKillswitchInterface
)
add_library(
qtdbusmock
SHARED
${QTDBUSMOCK_SRC}
)
qt5_use_modules(
qtdbusmock
Core
DBus
Test
)
target_link_libraries(
qtdbusmock
${QTDBUSTEST_LIBRARIES}
)
set_target_properties(
qtdbusmock
PROPERTIES
VERSION ${API_VERSION}.0.0
SOVERSION ${ABI_VERSION}
PUBLIC_HEADER "${QTDBUSMOCK_PUBLIC_HEADERS}"
)
install(
TARGETS qtdbusmock
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libqtdbusmock-${API_VERSION}/libqtdbusmock"
)
# Package config
set(LIBQTDBUSMOCK_PC "${CMAKE_CURRENT_BINARY_DIR}/libqtdbusmock-${API_VERSION}.pc")
configure_file("libqtdbusmock.pc.in" "${LIBQTDBUSMOCK_PC}" @ONLY)
install(
FILES "${LIBQTDBUSMOCK_PC}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
./src/libqtdbusmock/Method.h 0000644 0000041 0000041 00000003040 13062464635 016274 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
namespace QtDBusMock {
class Q_DECL_EXPORT Method {
public:
explicit Method();
Method(const Method &other);
Method& operator=(const Method &other);
~Method();
static void registerMetaType();
const QString & name() const;
const QString & inSig() const;
const QString & outSig() const;
const QString & code() const;
void setName(const QString &name);
void setInSig(const QString &inSig);
void setOutSig(const QString &outSig);
void setCode(const QString &code);
protected:
QString m_name;
QString m_inSig;
QString m_outSig;
QString m_code;
};
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const QtDBusMock::Method &method);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
QtDBusMock::Method &method);
Q_DECLARE_METATYPE(QtDBusMock::Method)
./src/libqtdbusmock/DBusMock.cpp 0000644 0000041 0000041 00000025206 13062464640 017062 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
using namespace QtDBusTest;
namespace QtDBusMock {
class DBusMockPrivate {
public:
DBusMockPrivate(DBusTestRunner &testRunner) :
m_testRunner(testRunner) {
}
QtDBusTest::DBusTestRunner &m_testRunner;
QScopedPointer m_networkManagerMock;
QScopedPointer m_notificationDaemonMock;
QScopedPointer m_ofonoInterface;
QMap> m_ofonoModemInterface;
QMap> m_ofonoSimManagerInterface;
QMap> m_ofonoConnectionManagerInterface;
QMap> m_ofonoNetworkRegistrationInterface;
QScopedPointer m_urfkillInterface;
QMap > m_urfkillKillSwitchInterfaces;
QMap > m_mockInterfaces;
};
DBusMock::DBusMock(DBusTestRunner &testRunner) :
d(new DBusMockPrivate(testRunner)) {
}
DBusMock::~DBusMock() {
}
void DBusMock::registerMetaTypes() {
Method::registerMetaType();
MethodCall::registerMetaType();
NamedMethodCall::registerMetaType();
qRegisterMetaType("QtDBusMock::VariantDictMap");
qDBusRegisterMetaType();
}
void DBusMock::registerTemplate(const QString &service,
const QString &templateName,
QDBusConnection::BusType busType) {
registerTemplate(service, templateName, QVariantMap(), busType);
}
void DBusMock::registerTemplate(const QString &service,
const QString &templateName,
const QVariantMap& parameters,
QDBusConnection::BusType busType) {
QStringList arguments;
arguments << "-m" << "dbusmock";
bool found = false;
if (!templateName.contains(QDir::separator())) {
auto dirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
for (const auto & dir : dirs) {
auto path = QDir(QDir(QDir(dir).filePath("libqtdbusmock")).filePath("templates")).filePath(templateName + ".py");
if (QFileInfo::exists(path)) {
arguments << "--template" << path;
found = true;
break;
}
}
}
if (!found) {
arguments << "--template" << templateName;
}
if (!parameters.isEmpty())
{
auto doc = QJsonDocument::fromVariant(parameters);
arguments << "--parameters" << QString::fromUtf8(doc.toJson(QJsonDocument::Compact));
}
d->m_testRunner.registerService(
DBusServicePtr(
new QProcessDBusService(service, busType, "python3",
arguments)));
}
void DBusMock::registerBluez5(const QVariantMap& parameters) {
registerTemplate("org.bluez", "bluez5", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerBluez4(const QVariantMap& parameters) {
registerTemplate("org.bluez", "bluez4", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerGnomeScreensaver(const QVariantMap& parameters) {
registerTemplate("org.gnome.ScreenSaver", "gnome_screensaver", parameters,
QDBusConnection::SessionBus);
}
void DBusMock::registerLogind(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.login1", "logind", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerNetworkManager() {
registerNetworkManager(QVariantMap());
}
void DBusMock::registerNetworkManager(const QVariantMap& parameters) {
registerTemplate(NM_DBUS_SERVICE, "networkmanager", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerNotificationDaemon() {
registerNotificationDaemon(QVariantMap());
}
void DBusMock::registerNotificationDaemon(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.Notifications", "notification_daemon",
parameters, QDBusConnection::SessionBus);
}
void DBusMock::registerOfono() {
registerOfono(QVariantMap());
}
void DBusMock::registerOfono(const QVariantMap& parameters) {
registerTemplate("org.ofono", "ofono", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerPolicyKit(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.PolicyKit1", "polkitd", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerTimeDate(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.timedate1", "timedated", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerHostname1(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.hostname1", "org.freedesktop.hostname1", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerLogin1(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.login1", "org.freedesktop.login1", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerURfkill() {
registerURfkill(QVariantMap());
}
void DBusMock::registerUpower(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.UPower", "upower", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerURfkill(const QVariantMap& parameters) {
registerTemplate("org.freedesktop.URfkill", "urfkill", parameters,
QDBusConnection::SystemBus);
}
void DBusMock::registerCustomMock(const QString &name, const QString &path,
const QString &interface, QDBusConnection::BusType busType) {
QStringList args;
args << "-m" << "dbusmock";
if (busType == QDBusConnection::SystemBus) {
args << "-s";
}
args << name << path << interface;
d->m_testRunner.registerService(
DBusServicePtr(
new QProcessDBusService(name, busType, "python3", args)));
}
NetworkManagerMockInterface & DBusMock::networkManagerInterface() {
if (d->m_networkManagerMock.isNull()) {
d->m_networkManagerMock.reset(
new NetworkManagerMockInterface(NM_DBUS_INTERFACE, NM_DBUS_PATH,
d->m_testRunner.systemConnection()));
}
return *d->m_networkManagerMock;
}
NotificationDaemonMockInterface & DBusMock::notificationDaemonInterface() {
if (d->m_notificationDaemonMock.isNull()) {
d->m_notificationDaemonMock.reset(
new NotificationDaemonMockInterface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
d->m_testRunner.sessionConnection()));
}
return *d->m_notificationDaemonMock;
}
OfonoMockInterface & DBusMock::ofonoInterface() {
if (d->m_ofonoInterface.isNull()) {
d->m_ofonoInterface.reset(
new OfonoMockInterface("org.ofono", "/",
d->m_testRunner.systemConnection()));
}
return *d->m_ofonoInterface;
}
OfonoModemInterface & DBusMock::ofonoModemInterface(const QString& path) {
QSharedPointer interface =
d->m_ofonoModemInterface[path];
if (!interface) {
interface.reset(
new OfonoModemInterface("org.ofono", path,
d->m_testRunner.systemConnection()));
d->m_ofonoModemInterface[path] = interface;
}
return *interface;
}
OfonoSimManagerInterface & DBusMock::ofonoSimManagerInterface(const QString& path) {
QSharedPointer interface =
d->m_ofonoSimManagerInterface[path];
if (!interface) {
interface.reset(
new OfonoSimManagerInterface("org.ofono", path,
d->m_testRunner.systemConnection()));
d->m_ofonoSimManagerInterface[path] = interface;
}
return *interface;
}
OfonoConnectionManagerInterface & DBusMock::ofonoConnectionManagerInterface(const QString& path) {
QSharedPointer interface =
d->m_ofonoConnectionManagerInterface[path];
if (!interface) {
interface.reset(
new OfonoConnectionManagerInterface("org.ofono", path,
d->m_testRunner.systemConnection()));
d->m_ofonoConnectionManagerInterface[path] = interface;
}
return *interface;
}
OfonoNetworkRegistrationInterface & DBusMock::ofonoNetworkRegistrationInterface(const QString& path) {
QSharedPointer interface =
d->m_ofonoNetworkRegistrationInterface[path];
if (!interface) {
interface.reset(
new OfonoNetworkRegistrationInterface("org.ofono", path,
d->m_testRunner.systemConnection()));
d->m_ofonoNetworkRegistrationInterface[path] = interface;
}
return *interface;
}
OrgFreedesktopURfkillInterface & DBusMock::urfkillInterface() {
if (d->m_urfkillInterface.isNull()) {
d->m_urfkillInterface.reset(
new OrgFreedesktopURfkillInterface(
"org.freedesktop.URfkill", "/org/freedesktop/URfkill",
d->m_testRunner.systemConnection()));
}
return *d->m_urfkillInterface;
}
OrgFreedesktopURfkillKillswitchInterface & DBusMock::urfkillKillswitchInterface(const QString& device)
{
QSharedPointer interface = d->m_urfkillKillSwitchInterfaces[device];
if (!interface) {
interface.reset(
new OrgFreedesktopURfkillKillswitchInterface(
"org.freedesktop.URfkill",
QString("/org/freedesktop/URfkill/%1").arg(device),
d->m_testRunner.systemConnection()));
d->m_urfkillKillSwitchInterfaces[device] = interface;
}
return *interface;
}
OrgFreedesktopDBusMockInterface & DBusMock::mockInterface(const QString &name,
const QString &path, const QString &interface,
QDBusConnection::BusType busType) {
Q_UNUSED(interface);
QString id(name);
id.append(':');
id.append(path);
auto it(d->m_mockInterfaces.find(id));
if (it == d->m_mockInterfaces.end()) {
switch (busType) {
case QDBusConnection::SystemBus:
it = d->m_mockInterfaces.insert(id,
QSharedPointer(
new OrgFreedesktopDBusMockInterface(name, path,
d->m_testRunner.systemConnection())));
break;
case QDBusConnection::SessionBus:
it = d->m_mockInterfaces.insert(id,
QSharedPointer(
new OrgFreedesktopDBusMockInterface(name, path,
d->m_testRunner.sessionConnection())));
break;
case QDBusConnection::ActivationBus:
qWarning() << "Unknown bus type";
break;
}
}
return **it;
}
}
./src/libqtdbusmock/config.h.in 0000644 0000041 0000041 00000001563 13062464635 016736 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef LIBQTDBUSMOCK_CONFIG_H_
#define LIBQTDBUSMOCK_CONFIG_H_
#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
#define LOCALE_DIR "@LOCALE_DIR@"
#endif // LIBQTDBUSMOCK_CONFIG_H_
./src/libqtdbusmock/libqtdbusmock.pc.in 0000644 0000041 0000041 00000000472 13062464635 020505 0 ustar www-data www-data libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Cflags: -I${includedir}/libqtdbusmock-@API_VERSION@
Requires: Qt5Core
Libs: -L${libdir} -lqtdbusmock -lqtdbustest
Name: libqtdbusmock
Description: A library to facilitate mocking DBus services written in Qt/C++
Version: @ABI_VERSION@
./src/libqtdbusmock/DBusMock.h 0000644 0000041 0000041 00000010114 13062464640 016517 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace QtDBusMock {
class DBusMockPrivate;
class Q_DECL_EXPORT DBusMock {
public:
DBusMock(QtDBusTest::DBusTestRunner &testRunner);
virtual ~DBusMock();
Q_DECL_EXPORT
static void registerMetaTypes();
virtual void registerTemplate(const QString &service,
const QString &templateName,
QDBusConnection::BusType busType);
virtual void registerTemplate(const QString &service,
const QString &templateName,
const QVariantMap& parameters,
QDBusConnection::BusType busType);
virtual void registerBluez4(const QVariantMap& parameters = QVariantMap());
virtual void registerBluez5(const QVariantMap& parameters = QVariantMap());
virtual void registerGnomeScreensaver(const QVariantMap& parameters = QVariantMap());
virtual void registerLogind(const QVariantMap& parameters = QVariantMap());
virtual void registerNetworkManager();
virtual void registerNetworkManager(const QVariantMap& parameters);
virtual void registerNotificationDaemon();
virtual void registerNotificationDaemon(const QVariantMap& parameters);
virtual void registerOfono();
virtual void registerOfono(const QVariantMap& parameters);
virtual void registerPolicyKit(const QVariantMap& parameters = QVariantMap());
virtual void registerTimeDate(const QVariantMap& parameters = QVariantMap());
virtual void registerHostname1(const QVariantMap& parameters = QVariantMap());
virtual void registerLogin1(const QVariantMap& parameters = QVariantMap());
virtual void registerURfkill();
virtual void registerURfkill(const QVariantMap& parameters);
virtual void registerUpower(const QVariantMap& parameters = QVariantMap());
virtual void registerCustomMock(const QString &name, const QString &path,
const QString &interface, QDBusConnection::BusType);
virtual NetworkManagerMockInterface & networkManagerInterface();
virtual NotificationDaemonMockInterface & notificationDaemonInterface();
virtual OrgFreedesktopDBusMockInterface & mockInterface(const QString &name,
const QString &path, const QString &interface,
QDBusConnection::BusType busType);
virtual OfonoMockInterface & ofonoInterface();
virtual OfonoModemInterface & ofonoModemInterface(const QString &path);
virtual OfonoSimManagerInterface & ofonoSimManagerInterface(const QString &path);
virtual OfonoConnectionManagerInterface & ofonoConnectionManagerInterface(const QString &path);
virtual OfonoNetworkRegistrationInterface & ofonoNetworkRegistrationInterface(const QString &path);
virtual OrgFreedesktopURfkillInterface & urfkillInterface();
virtual OrgFreedesktopURfkillKillswitchInterface & urfkillKillswitchInterface(const QString& device);
private:
QSharedPointer d;
};
}
./src/libqtdbusmock/DeclareMetatypes.h 0000644 0000041 0000041 00000001466 13062464635 020321 0 ustar www-data www-data /*
* Copyright (C) 2016 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
#include
Q_DECLARE_METATYPE(QMap)
./src/libqtdbusmock/MethodCall.h 0000644 0000041 0000041 00000002664 13062464635 017103 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
namespace QtDBusMock {
class Q_DECL_EXPORT MethodCall {
public:
explicit MethodCall();
MethodCall(const MethodCall &other);
MethodCall& operator=(const MethodCall &other);
~MethodCall();
static void registerMetaType();
const quint64 & timestamp() const;
const QVariantList & args() const;
void setTimestamp(quint64 timestamp);
void setArgs(const QVariantList &args);
protected:
quint64 m_timestamp;
QVariantList m_args;
};
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const QtDBusMock::MethodCall &methodCalls);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
QtDBusMock::MethodCall &methodCalls);
Q_DECLARE_METATYPE(QtDBusMock::MethodCall)
./src/libqtdbusmock/ExportInterfaces.h 0000644 0000041 0000041 00000002151 13062464635 020343 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
class Q_DECL_EXPORT OrgFreedesktopDBusMockInterface;
class Q_DECL_EXPORT NetworkManagerMockInterface;
class Q_DECL_EXPORT OrgFreedesktopDBusPropertiesInterface;
namespace QtDBusMock {
typedef QMap VariantDictMap;
}
#include
#include
#include
./src/libqtdbusmock/MockInterfaceClasses.h 0000644 0000041 0000041 00000001560 13062464635 021111 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
#include
#include
#include
./src/libqtdbusmock/Method.cpp 0000644 0000041 0000041 00000004527 13062464635 016642 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace QtDBusMock;
Method::Method() {
}
Method::Method(const Method &other) :
m_name(other.m_name), m_inSig(other.m_inSig), m_outSig(other.m_outSig), m_code(
other.m_code) {
}
Method& Method::operator=(const Method &other) {
m_name = other.m_name;
m_inSig = other.m_inSig;
m_outSig = other.m_outSig;
m_code = other.m_code;
return *this;
}
Method::~Method() {
}
void Method::registerMetaType() {
qRegisterMetaType("QtDBusMock::Method");
qDBusRegisterMetaType();
qDBusRegisterMetaType>();
}
const QString & Method::name() const {
return m_name;
}
void Method::setName(const QString &name) {
m_name = name;
}
const QString & Method::inSig() const {
return m_inSig;
}
void Method::setInSig(const QString &inSig) {
m_inSig = inSig;
}
const QString & Method::outSig() const {
return m_outSig;
}
void Method::setOutSig(const QString &outSig) {
m_outSig = outSig;
}
const QString & Method::code() const {
return m_code;
}
void Method::setCode(const QString &code) {
m_code = code;
}
QDBusArgument &operator<<(QDBusArgument &argument, const Method& method) {
argument.beginStructure();
argument << method.name() << method.inSig() << method.outSig()
<< method.code();
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, Method &method) {
QString name;
QString inSig;
QString outSig;
QString code;
argument.beginStructure();
argument >> name >> inSig >> outSig >> code;
argument.endStructure();
method.setName(name);
method.setInSig(inSig);
method.setOutSig(outSig);
method.setCode(code);
return argument;
}
./src/libqtdbusmock/MethodCall.cpp 0000644 0000041 0000041 00000006516 13062464635 017436 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace QtDBusMock;
MethodCall::MethodCall() :
m_timestamp(0) {
}
MethodCall::MethodCall(const MethodCall &other) :
m_timestamp(other.m_timestamp), m_args(other.m_args) {
}
MethodCall& MethodCall::operator=(const MethodCall &other) {
m_timestamp = other.m_timestamp;
m_args = other.m_args;
return *this;
}
MethodCall::~MethodCall() {
}
void MethodCall::registerMetaType() {
qRegisterMetaType("QtDBusMock::MethodCall");
qDBusRegisterMetaType();
qDBusRegisterMetaType>();
}
const quint64 & MethodCall::timestamp() const {
return m_timestamp;
}
const QVariantList & MethodCall::args() const {
return m_args;
}
void MethodCall::setTimestamp(quint64 timestamp) {
m_timestamp = timestamp;
}
void MethodCall::setArgs(const QVariantList &args) {
m_args = args;
}
QDBusArgument &operator<<(QDBusArgument &argument,
const MethodCall& methodCall) {
argument.beginStructure();
argument << methodCall.timestamp() << methodCall.args();
argument.endStructure();
return argument;
}
static void transform(QVariantList &list);
static void transform(QVariantMap &map);
static QVariant transform(const QDBusArgument & value) {
switch (value.currentType()) {
case QDBusArgument::ArrayType: {
value.beginArray();
QVariantList list = transform(value).toList();
value.endArray();
return list;
}
case QDBusArgument::MapType: {
QVariantMap map;
value >> map;
transform(map);
return map;
}
case QDBusArgument::StructureType: {
value.beginStructure();
QVariantList list;
while (!value.atEnd()) {
list << value.asVariant();
}
value.endStructure();
return list;
break;
}
default:
qDebug() << "Unhandled type" << value.currentType()
<< value.currentSignature();
}
return QVariant();
}
static void transform(QVariant &variant) {
if (variant.canConvert()) {
QVariantList list = variant.toList();
transform(list);
variant = list;
} else if (variant.canConvert()) {
QDBusArgument value(variant.value());
variant = transform(value);
}
}
static void transform(QVariantMap &map) {
for (auto it(map.begin()); it != map.end(); ++it) {
transform(*it);
}
}
static void transform(QVariantList &list) {
for (auto it(list.begin()); it != list.end(); ++it) {
transform(*it);
}
}
const QDBusArgument &operator>>(const QDBusArgument &argument,
MethodCall &methodCall) {
quint64 timestamp;
QVariantList args;
argument.beginStructure();
argument >> timestamp >> args;
argument.endStructure();
transform(args);
methodCall.setTimestamp(timestamp);
methodCall.setArgs(args);
return argument;
}
./src/libqtdbusmock/NamedMethodCall.h 0000644 0000041 0000041 00000003125 13062464635 020041 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#pragma once
#include
namespace QtDBusMock {
class Q_DECL_EXPORT NamedMethodCall {
public:
explicit NamedMethodCall();
NamedMethodCall(const NamedMethodCall &other);
NamedMethodCall& operator=(const NamedMethodCall &other);
~NamedMethodCall();
static void registerMetaType();
const QString & methodName() const;
void setMethodName(const QString &methodName);
const quint64 & timestamp() const;
const QVariantList & args() const;
void setTimestamp(quint64 timestamp);
void setArgs(const QVariantList &args);
protected:
quint64 m_timestamp;
QString m_methodName;
QVariantList m_args;
};
}
Q_DECL_EXPORT
QDBusArgument &operator<<(QDBusArgument &argument,
const QtDBusMock::NamedMethodCall &methodCalls);
Q_DECL_EXPORT
const QDBusArgument &operator>>(const QDBusArgument &argument,
QtDBusMock::NamedMethodCall &methodCalls);
Q_DECLARE_METATYPE(QtDBusMock::NamedMethodCall)
./src/libqtdbusmock/NamedMethodCall.cpp 0000644 0000041 0000041 00000005004 13062464635 020372 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
using namespace QtDBusMock;
NamedMethodCall::NamedMethodCall() :
m_timestamp(0) {
}
NamedMethodCall::NamedMethodCall(const NamedMethodCall &other) :
m_timestamp(other.m_timestamp), m_methodName(other.m_methodName), m_args(
other.m_args) {
}
NamedMethodCall& NamedMethodCall::operator=(const NamedMethodCall &other) {
m_timestamp = other.m_timestamp;
m_methodName = other.m_methodName;
m_args = other.m_args;
return *this;
}
NamedMethodCall::~NamedMethodCall() {
}
void NamedMethodCall::registerMetaType() {
qRegisterMetaType("QtDBusMock::NamedMethodCall");
qDBusRegisterMetaType();
qDBusRegisterMetaType>();
}
const QString & NamedMethodCall::methodName() const {
return m_methodName;
}
const quint64 & NamedMethodCall::timestamp() const {
return m_timestamp;
}
const QVariantList & NamedMethodCall::args() const {
return m_args;
}
void NamedMethodCall::setMethodName(const QString &methodName) {
m_methodName = methodName;
}
void NamedMethodCall::setTimestamp(quint64 timestamp) {
m_timestamp = timestamp;
}
void NamedMethodCall::setArgs(const QVariantList &args) {
m_args = args;
}
QDBusArgument &operator<<(QDBusArgument &argument,
const NamedMethodCall& methodCall) {
argument.beginStructure();
argument << methodCall.timestamp() << methodCall.methodName()
<< methodCall.args();
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument,
NamedMethodCall &methodCall) {
quint64 timestamp;
QString methodName;
QVariantList args;
argument.beginStructure();
argument >> timestamp >> methodName >> args;
argument.endStructure();
methodCall.setTimestamp(timestamp);
methodCall.setMethodName(methodName);
methodCall.setArgs(args);
return argument;
}
./templates/ 0000755 0000041 0000041 00000000000 13062464640 013246 5 ustar www-data www-data ./templates/CMakeLists.txt 0000644 0000041 0000041 00000000225 13062464640 016005 0 ustar www-data www-data
install(
FILES
"org.freedesktop.hostname1.py"
"org.freedesktop.login1.py"
DESTINATION
"${CMAKE_INSTALL_DATADIR}/libqtdbusmock/templates/"
)
./templates/org.freedesktop.hostname1.py 0000644 0000041 0000041 00000004703 13062464640 020623 0 ustar www-data www-data '''Hostname1 mock template
'''
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.
__author__ = 'Pete Woods'
__email__ = 'pete.woods@canonical.com'
__copyright__ = '(c) 2016 Canonical Ltd.'
__license__ = 'LGPL 3+'
import dbus
import uuid
import binascii
from dbusmock import MOCK_IFACE
import dbusmock
BUS_NAME = 'org.freedesktop.hostname1'
MAIN_IFACE = 'org.freedesktop.hostname1'
MAIN_OBJ = '/org/freedesktop/hostname1'
SYSTEM_BUS = True
def load(mock, parameters):
mock.AddProperties(MAIN_IFACE, {
'Hostname': parameters.get('Hostname', 'my-computer'),
'StaticHostname': parameters.get('StaticHostname', 'ubuntu'),
'PrettyHostname': parameters.get('PrettyHostname', ''),
'IconName': parameters.get('IconName', 'computer-vm'), # e.g. "computer-laptop", "computer-desktop"
'Chassis': parameters.get('Chassis', 'vm'), # currently defined set: "desktop", "laptop", "server", "tablet", "handset", "vm" and "container"
'Deployment': parameters.get('Deployment', ''),
'Location': parameters.get('Location', ''),
'KernelName': parameters.get('KernelName', 'Linux'),
'KernelRelease': parameters.get('KernelRelease', '4.4.0-53-generic'),
'KernelVersion': parameters.get('KernelVersion', '#74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016'),
'OperatingSystemPrettyName': parameters.get('OperatingSystemPrettyName', 'Ubuntu 16.04.1 LTS'),
'OperatingSystemCPEName': parameters.get('OperatingSystemCPEName', ''),
})
mock.AddMethods(MAIN_IFACE, [
('SetHostname', 'sb', '', "ret = self.Set('%s', 'Hostname', args[0])" % MAIN_IFACE),
('SetStaticHostname', 'sb', '', "ret = self.Set('%s', 'StaticHostname', args[0])" % MAIN_IFACE),
('SetPrettyHostname', 'sb', '', "ret = self.Set('%s', 'PrettyHostname', args[0])" % MAIN_IFACE),
('SetIconName', 'sb', '', "ret = self.Set('%s', 'IconName', args[0])" % MAIN_IFACE),
('SetChassis', 'sb', '', "ret = self.Set('%s', 'Chassis', args[0])" % MAIN_IFACE),
('SetDeployment', 'sb', '', "ret = self.Set('%s', 'Deployment', args[0])" % MAIN_IFACE),
('SetLocation', 'sb', '', "ret = self.Set('%s', 'Location', args[0])" % MAIN_IFACE),
])
./templates/org.freedesktop.login1.py 0000644 0000041 0000041 00000015470 13062464640 020120 0 ustar www-data www-data '''Login1 mock template
'''
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.
__author__ = 'Pete Woods'
__email__ = 'pete.woods@canonical.com'
__copyright__ = '(c) 2017 Canonical Ltd.'
__license__ = 'LGPL 3+'
import dbus
import uuid
import binascii
from dbusmock import MOCK_IFACE
import dbusmock
BUS_NAME = 'org.freedesktop.login1'
MAIN_IFACE = 'org.freedesktop.login1.Manager'
MAIN_OBJ = '/org/freedesktop/login1'
SYSTEM_BUS = True
SEAT_IFACE = 'org.freedesktop.login1.Seat'
SEAT_PATH = '/org/freedesktop/login1/seat/'
def load(mock, parameters):
mock.seats = {}
add_seat(mock, parameters.get('DefaultSeat', {}), True)
mock.list_seats = list_seats
mock.get_seat = get_seat
mock.AddProperties(MAIN_IFACE, {
'EnableWallMessages': parameters.get('EnableWallMessages', False),
'WallMessage': parameters.get('WallMessage', ''),
'NAutoVTs': parameters.get('NAutoVTs', dbus.UInt32(6)),
'KillOnlyUsers': parameters.get('KillOnlyUsers', dbus.Array([], signature='s')),
'KillExcludeUsers': parameters.get('KillExcludeUsers', dbus.Array(['root'], signature='s')),
'KillUserProcesses': parameters.get('KillUserProcesses', False),
'RebootToFirmwareSetup': parameters.get('RebootToFirmwareSetup', False),
'IdleHint': parameters.get('IdleHint', False),
'IdleSinceHint': parameters.get('IdleSinceHint', dbus.UInt64(1489580452083866)),
'IdleSinceHintMonotonic': parameters.get('IdleSinceHintMonotonic', dbus.UInt64(8134597164)),
'BlockInhibited': parameters.get('BlockInhibited', 'handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch'),
'DelayInhibited': parameters.get('DelayInhibited', 'sleep'),
'InhibitDelayMaxUSec': parameters.get('InhibitDelayMaxUSec', dbus.UInt64(5000000)),
'HandlePowerKey': parameters.get('HandlePowerKey', 'poweroff'),
'HandleSuspendKey': parameters.get('HandleSuspendKey', 'suspend'),
'HandleHibernateKey': parameters.get('HandleHibernateKey', 'hibernate'),
'HandleLidSwitch': parameters.get('HandleLidSwitch', 'suspend'),
'HandleLidSwitchDocked': parameters.get('HandleLidSwitchDocked', 'ignore'),
'HoldoffTimeoutUSec': parameters.get('HoldoffTimeoutUSec', dbus.UInt64(30000000)),
'IdleAction': parameters.get('IdleAction', 'ignore'),
'IdleActionUSec': parameters.get('IdleActionUSec', dbus.UInt64(1800000000)),
'PreparingForShutdown': parameters.get('PreparingForShutdown', False),
'PreparingForSleep': parameters.get('PreparingForSleep', False),
'ScheduledShutdown': parameters.get('ScheduledShutdown', dbus.Struct(('', 0), signature='st')),
'Docked': parameters.get('Docked', False),
})
mock.AddMethods(MAIN_IFACE, [
('GetSession', 's', 'o', "ret = dbus.ObjectPath('/')"),
('GetSessionByPID', 'u', 'o', "ret = dbus.ObjectPath('/')"),
('GetUser', 'u', 'o', "ret = dbus.ObjectPath('/')"),
('GetUserByPID', 'u', 'o', "ret = dbus.ObjectPath('/')"),
('GetSeat', 's', 'o', "ret = self.get_seat(self, args[0])"),
('ListSessions', '', 'a(susso)', ""),
('ListUsers', '', 'a(uso)', ""),
('ListSeats', '', 'a(so)', "ret = self.list_seats(self)"),
('ListInhibitors', '', 'a(ssssuu)', ""),
('CreateSession', 'uusssssussbssa(sv)', 'soshusub', ""),
('ReleaseSession', 's', '', ""),
('ActivateSession', 's', '', ""),
('ActivateSessionOnSeat', 'ss', '', ""),
('LockSession', 's', '', ""),
('UnlockSession', 's', '', ""),
('LockSessions', '', '', ""),
('UnlockSessions', '', '', ""),
('KillSession', 'ssi', '', ""),
('KillUser', 'ui', '', ""),
('TerminateSession', 's', '', ""),
('TerminateUser', 'u', '', ""),
('TerminateSeat', 's', '', ""),
('SetUserLinger', 'ubb', '', ""),
('AttachDevice', 'ssb', '', ""),
('FlushDevices', 'b', '', ""),
('PowerOff', 'b', '', ""),
('Reboot', 'b', '', ""),
('Suspend', 'b', '', ""),
('Hibernate', 'b', '', ""),
('HybridSleep', 'b', '', ""),
('CanPowerOff', '', 's', "ret = ''"),
('CanReboot', '', 's', "ret = ''"),
('CanSuspend', '', 's', "ret = ''"),
('CanHibernate', '', 's', "ret = ''"),
('CanHybridSleep', '', 's', "ret = ''"),
('ScheduleShutdown', 'st', '', ""),
('CancelScheduledShutdown', '', 'b', "ret = False"),
('Inhibit', 'ssss', 'h', "ret = ?"),
('CanRebootToFirmwareSetup', '', 's', "ret = ''"),
('SetRebootToFirmwareSetup', 'b', '', ""),
('SetWallMessage', 'sb', '', ""),
])
def add_seat(self, properties, is_self):
# find a new name
count = 0
while True:
id = 'seat%d' % count
if id not in self.seats:
break
count += 1
path = dbus.ObjectPath(SEAT_PATH + id)
seat_props = {
'Id': id,
'ActiveSession': properties.get('ActiveSession', dbus.Struct(('c2', '/org/freedesktop/login1/session/c2'), signature='so')),
'CanMultiSession': properties.get('CanMultiSession', True),
'CanTTY': properties.get('CanTTY', True),
'CanGraphical': properties.get('CanGraphical', True),
'Sessions': properties.get('Sessions', dbus.Array([('c2', '/org/freedesktop/login1/session/c2')], signature='(so)')),
'IdleHint': properties.get('IdleHint', False),
'IdleSinceHint': properties.get('IdleSinceHint', dbus.UInt64(1489590854604069)),
'IdleSinceHintMonotonic': properties.get('IdleSinceHintMonotonic', dbus.UInt64(18537117367)),
}
seat_methods = [
('Terminate', '', '', ""),
('ActivateSession', 's', '', ""),
('SwitchTo', 'u', '', ""),
('SwitchToNext', '', '', ""),
('SwitchToPrevious', '', '', ""),
]
self.seats[id] = self.AddObject(path,
SEAT_IFACE,
seat_props,
seat_methods)
if is_self:
self_path = dbus.ObjectPath(SEAT_PATH + 'self')
try:
self.RemoveObject(self_path)
except dbus.exceptions.DBusException:
pass
self.AddObject(self_path,
SEAT_IFACE,
seat_props,
seat_methods)
return path
def get_seat(self, id):
if id in self.seats:
return SEAT_PATH + id
raise dbus.exceptions.DBusException()
def list_seats(self):
result = dbus.Array([], signature='(so)')
for id in self.seats:
result.append((id, SEAT_PATH + id))
return result
./tests/ 0000755 0000041 0000041 00000000000 13062464635 012416 5 ustar www-data www-data ./tests/CMakeLists.txt 0000644 0000041 0000041 00000001021 13062464635 015150 0 ustar www-data www-data
set(CMAKE_AUTOMOC OFF)
find_package(GMock REQUIRED)
set(CMAKE_AUTOMOC ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${GMOCK_INCLUDE_DIRS})
include_directories(${GTEST_INCLUDE_DIRS})
set(
UNIT_TESTS_SRC
main.cpp
libqtdbusmock/TestDBusMock.cpp
)
add_executable(
unit-tests
${UNIT_TESTS_SRC}
)
qt5_use_modules(
unit-tests
Core
DBus
Test
)
target_link_libraries(
unit-tests
qtdbusmock
${QTDBUSTEST_LIBRARIES}
${GTEST_LIBRARIES}
${GMOCK_LIBRARIES}
)
add_test(
unit-tests
unit-tests
)
./tests/main.cpp 0000644 0000041 0000041 00000002346 13062464635 014053 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
using namespace QtDBusMock;
int main(int argc, char **argv) {
// qputenv("LANG", "C.UTF-8");
// unsetenv("LC_ALL");
// setlocale(LC_ALL, "");
// bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
// textdomain(GETTEXT_PACKAGE);
QCoreApplication application(argc, argv);
DBusMock::registerMetaTypes();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
./tests/libqtdbusmock/ 0000755 0000041 0000041 00000000000 13062464635 015261 5 ustar www-data www-data ./tests/libqtdbusmock/TestDBusMock.cpp 0000644 0000041 0000041 00000020524 13062464635 020277 0 ustar www-data www-data /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of version 3 of the GNU Lesser General Public License as published
* by the Free Software Foundation.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace testing;
using namespace QtDBusTest;
using namespace QtDBusMock;
namespace {
class TestDBusMock: public Test {
protected:
TestDBusMock() :
dbusMock(dbusTestRunner) {
}
virtual ~TestDBusMock() {
}
bool processListContains(const char *str) {
QProcess pgrep;
pgrep.start("ps",
QStringList() << "--no-headers" << "--ppid"
<< QString::number(QCoreApplication::applicationPid())
<< "-o" << "args");
pgrep.waitForFinished();
pgrep.waitForReadyRead();
return pgrep.readAll().contains(str);
}
DBusTestRunner dbusTestRunner;
DBusMock dbusMock;
};
TEST_F(TestDBusMock, StartsDBusMockSession) {
dbusMock.registerCustomMock("test.name", "/test/object", "test.Interface",
QDBusConnection::SessionBus);
dbusTestRunner.startServices();
EXPECT_TRUE(
processListContains(
"python3 -m dbusmock test.name /test/object test.Interface"));
}
TEST_F(TestDBusMock, StartsDBusMockSystem) {
dbusMock.registerCustomMock("test.name2", "/test/object2",
"test.Interface2", QDBusConnection::SystemBus);
dbusTestRunner.startServices();
EXPECT_TRUE(
processListContains(
"python3 -m dbusmock -s test.name2 /test/object2 test.Interface2"));
}
TEST_F(TestDBusMock, StartsDBusMockWithNM) {
dbusMock.registerNetworkManager();
dbusTestRunner.startServices();
EXPECT_TRUE(
processListContains(
"python3 -m dbusmock --template networkmanager"));
NetworkManagerMockInterface &networkManager(
dbusMock.networkManagerInterface());
networkManager.AddWiFiDevice("device", "eth1", NM_STATE_DISCONNECTED).waitForFinished();
QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH,
NM_DBUS_INTERFACE,
dbusTestRunner.systemConnection());
QDBusReply > devices = iface.call("GetDevices");
ASSERT_EQ(true, devices.isValid());
ASSERT_EQ(1, devices.value().size());
}
TEST_F(TestDBusMock, StartsDBusMockTemplateParameters) {
dbusMock.registerUpower({{"DaemonVersion", "0.99.0"}, {"OnBattery", true}});
dbusTestRunner.startServices();
EXPECT_TRUE(
processListContains(
"python3 -m dbusmock --template upower --parameters {\"DaemonVersion\":\"0.99.0\",\"OnBattery\":true}"));
QDBusInterface iface("org.freedesktop.UPower", "/org/freedesktop/UPower",
"org.freedesktop.UPower", dbusTestRunner.systemConnection());
EXPECT_EQ("0.99.0", iface.property("DaemonVersion").toString());
EXPECT_TRUE(iface.property("OnBattery").toBool());
}
TEST_F(TestDBusMock, StartsDBusMockWithTemplate) {
dbusMock.registerTemplate(NM_DBUS_SERVICE,
"networkmanager",
QDBusConnection::SystemBus);
dbusTestRunner.startServices();
EXPECT_TRUE(
processListContains(
"python3 -m dbusmock --template networkmanager"));
NetworkManagerMockInterface &networkManager(
dbusMock.networkManagerInterface());
networkManager.AddWiFiDevice("device", "eth1", NM_STATE_DISCONNECTED).waitForFinished();
QDBusInterface iface (NM_DBUS_SERVICE, NM_DBUS_PATH,
NM_DBUS_INTERFACE,
dbusTestRunner.systemConnection());
QDBusReply > devices = iface.call("GetDevices");
ASSERT_EQ(true, devices.isValid());
ASSERT_EQ(1, devices.value().size());
}
TEST_F(TestDBusMock, GetMethodCalls) {
dbusMock.registerCustomMock("test.name", "/test/path", "test.interface",
QDBusConnection::SessionBus);
dbusTestRunner.startServices();
OrgFreedesktopDBusMockInterface &mockInterface(
dbusMock.mockInterface("test.name", "/test/path", "test.interface",
QDBusConnection::SessionBus));
mockInterface.AddMethod("test.interface", "MethodName", "s", "s",
"ret = 'output'").waitForFinished();
QDBusMessage message(
QDBusMessage::createMethodCall("test.name", "/test/path",
"test.interface", "MethodName"));
message.setArguments(QVariantList() << QVariant("input"));
QDBusMessage reply(dbusTestRunner.sessionConnection().call(message));
ASSERT_EQ(1, reply.arguments().size());
EXPECT_EQ("output", reply.arguments().first().toString().toStdString());
QList methodCalls(mockInterface.GetMethodCalls("MethodName"));
ASSERT_EQ(1, methodCalls.size());
MethodCall call;
call = methodCalls.first();
ASSERT_EQ(1, call.args().size());
EXPECT_EQ("input", call.args().first().toString().toStdString());
}
TEST_F(TestDBusMock, GetAllMethodCalls) {
dbusMock.registerCustomMock("test.name", "/test/path", "test.interface",
QDBusConnection::SessionBus);
dbusTestRunner.startServices();
OrgFreedesktopDBusMockInterface &mockInterface(
dbusMock.mockInterface("test.name", "/test/path", "test.interface",
QDBusConnection::SessionBus));
mockInterface.AddMethod("test.interface", "MethodName", "s", "s",
"ret = 'output'").waitForFinished();
QDBusMessage message(
QDBusMessage::createMethodCall("test.name", "/test/path",
"test.interface", "MethodName"));
message.setArguments(QVariantList() << QVariant("input"));
QDBusMessage reply(dbusTestRunner.sessionConnection().call(message));
ASSERT_EQ(1, reply.arguments().size());
EXPECT_EQ("output", reply.arguments().first().toString().toStdString());
QList methodCalls(mockInterface.GetCalls());
ASSERT_EQ(1, methodCalls.size());
NamedMethodCall call;
call = methodCalls.first();
EXPECT_EQ("MethodName", call.methodName().toStdString());
ASSERT_EQ(1, call.args().size());
EXPECT_EQ("input", call.args().first().toString().toStdString());
}
TEST_F(TestDBusMock, AddMethods) {
dbusMock.registerCustomMock("test.name", "/test/path", "test.interface",
QDBusConnection::SessionBus);
dbusTestRunner.startServices();
OrgFreedesktopDBusMockInterface &mockInterface(
dbusMock.mockInterface("test.name", "/test/path", "test.interface",
QDBusConnection::SessionBus));
Method method1;
method1.setName("MethodName1");
method1.setInSig("s");
method1.setOutSig("s");
method1.setCode("ret = 'output1'");
Method methodTemp;
methodTemp.setName("MethodName2");
methodTemp.setInSig("u");
methodTemp.setOutSig("s");
methodTemp.setCode("ret = 'output2'");
Method method2;
method2 = methodTemp;
mockInterface.AddMethods("test.interface",
QList() << method1 << method2).waitForFinished();
{
QDBusMessage message(
QDBusMessage::createMethodCall("test.name", "/test/path",
"test.interface", "MethodName1"));
message.setArguments(QVariantList() << QVariant("input"));
QDBusMessage reply(dbusTestRunner.sessionConnection().call(message));
ASSERT_EQ(1, reply.arguments().size());
EXPECT_EQ("output1",
reply.arguments().first().toString().toStdString());
}
{
QDBusMessage message(
QDBusMessage::createMethodCall("test.name", "/test/path",
"test.interface", "MethodName2"));
message.setArguments(QVariantList() << QVariant(123));
QDBusMessage reply(dbusTestRunner.sessionConnection().call(message));
ASSERT_EQ(1, reply.arguments().size());
EXPECT_EQ("output2",
reply.arguments().first().toString().toStdString());
}
QList methodCalls(mockInterface.GetCalls());
ASSERT_EQ(2, methodCalls.size());
{
NamedMethodCall call;
call = methodCalls.first();
EXPECT_EQ("MethodName1", call.methodName().toStdString());
ASSERT_EQ(1, call.args().size());
EXPECT_EQ("input", call.args().first().toString().toStdString());
}
{
NamedMethodCall call;
call = methodCalls[1];
EXPECT_EQ("MethodName2", call.methodName().toStdString());
ASSERT_EQ(1, call.args().size());
EXPECT_EQ(123, call.args().first().toUInt());
}
}
} // namespace
./tests/data/ 0000755 0000041 0000041 00000000000 13062464635 013327 5 ustar www-data www-data ./tests/data/valgrind.suppression 0000644 0000041 0000041 00000001544 13062464635 017455 0 ustar www-data www-data {
Ignore pthreads
Memcheck:Leak
...
fun:pthread_create@@*
}
{
Glib memalign
Memcheck:Leak
...
fun:posix_memalign
}
{
Ignore glib mainloop
Memcheck:Leak
...
fun:g_main_context_push_thread_default
}
{
Ignore glib main context
Memcheck:Leak
...
fun:g_main_context_new
}
{
False positive leak on strings in i386
Memcheck:Leak
fun:_Znwj
fun:_ZNSs4_Rep9_S_createEjjRKSaIcE
...
fun:_ZN7testing14InitGoogleTestEPiPPc
fun:(below main)
}
{
False positive leak on strings on i386
Memcheck:Leak
fun:_Znwj
fun:_ZNSs4_Rep9_S_createEjjRKSaIcE
...
fun:__libc_csu_init
fun:(below main)
}
{
Qt apparently has some statically allocated data here
Memcheck:Leak
fun:calloc
fun:allocate_dtv
fun:_ZN7QThread5startENS_8PriorityE
obj:/usr/lib/*/libQt5Core.so.*
...
obj:*
}
./build.sh 0000755 0000041 0000041 00000002674 13062464635 012723 0 ustar www-data www-data #! /bin/bash
set -e
ECLIPSE=false
CLEAN=false
SOURCEDIR="$PWD"
BRANCHNAME=`basename $SOURCEDIR`
BUILDDIR="$SOURCEDIR/../$BRANCHNAME-build"
usage() {
echo "usage: $0 [OPTIONS] [BUILD_TYPE]\n" >&2
echo "Script to build libqtdbusmock. If BUILD_TYPE is not specified, it defaults to \"Debug\".\n" >&2
echo "OPTIONS:" >&2
echo " -e, --eclipse Generate Eclipse projects" >&2
echo " -c, --clean Clean the build tree before building" >&2
echo >&2
exit 1
}
ARGS=`getopt -n$0 -u -a --longoptions="eclipse,clean,help" -o "sch" -- "$@"`
[ $? -ne 0 ] && usage
eval set -- "$ARGS"
while [ $# -gt 0 ]
do
case "$1" in
-e|--eclipse) ECLIPSE=true;;
-c|--clean) CLEAN=true;;
-h|--help) usage;;
--) shift;break;;
esac
shift
done
[ $# -gt 1 ] && usage
BUILD_TYPE="Debug"
[ $# -eq 1 ] && BUILD_TYPE="$1"
if [ -f "/usr/bin/ninja" ] ; then
if $ECLIPSE; then
GENERATOR="Eclipse CDT4 - Ninja"
else
GENERATOR="Ninja"
fi
BUILD_COMMAND="ninja"
else
if $ECLIPSE; then
GENERATOR="Eclipse CDT4 - Unix Makefiles"
else
GENERATOR="Unix Makefiles"
fi
BUILD_COMMAND="make"
fi
echo "Using $BUILD_COMMAND to build"
if $CLEAN; then
rm -rf $BUILDDIR
fi
mkdir -p $BUILDDIR
(
cd $BUILDDIR
cmake "$SOURCEDIR" -G "$GENERATOR" \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DENABLE_MEMCHECK_OPTION=YES \
-DCMAKE_INSTALL_PREFIX="$SOURCEDIR/../$BRANCHNAME-install"
$BUILD_COMMAND
)
./data/ 0000755 0000041 0000041 00000000000 13062464635 012165 5 ustar www-data www-data ./data/ofono-connectionmanager.xml 0000644 0000041 0000041 00000001120 13062464635 017511 0 ustar www-data www-data
./data/CMakeLists.txt 0000644 0000041 0000041 00000000000 13062464635 014713 0 ustar www-data www-data ./data/org.freedesktop.URfkill.xml 0000644 0000041 0000041 00000027574 13062464635 017376 0 ustar www-data www-data
The urfkill service is available via the system message
bus. To access the service, use
the org.freedesktop.URfkill interface on
the /org/freedesktop/URfkill object on
the D-Bus system bus service with the well-known
name org.freedesktop.URfkill.
$ gdbus call -y \
-d org.freedesktop.URfkill \
-o /org/freedesktop/URfkill \
-m org.freedesktop.URfkill.EnumerateDevices
([objectpath '/org/freedesktop/URfkill/devices/0', '/org/freedesktop/URfkill/devices/1'],)
The type of devices to be blocked/unblocked
TRUE to block the devices, FALSE to unblock
TRUE for success, otherwise FALSE
Block or unblock the devices belonging to the type.
The types are defined as the followings:
0All
1WLAN
2Bluetooth
3UWB
4WIMAX
5WWAN
6GPS
7FM
Note: This method only changes soft block. Hard block is controlled
by BIOS or the hardware and there is no way to change the
state of hard block through kernel functions.
This method is restricted to the active session user.
The index of the device to be blocked/unblocked
TRUE to block the device, FALSE to unblock
TRUE for success, otherwise FALSE
Block or unblock the device by the index.
Note: This method only changes soft block. Hard block is controlled
by BIOS or the hardware and there is no way to change the
state of hard block through kernel functions.
This method is restricted to the currently active session user.
An array of the object pathes for the devices
Enumerate all rfkill objects on the system.
TRUE of flight mode should be enabled, otherwise FALSE
TRUE if successful, otherwise FALSE
Enable or disable flight mode.
TRUE if flight mode is enabled, otherwise FALSE
Get whether flight mode is enabled or not.
TRUE if the key control is inhibited, otherwise FALSE
Get whether the rfkill key handling function is inhibited or not.
The reason to inhibit the key control
The cookie
Inhibit the rfkill key handling function for the session.
The cookie
Cancel a previous call to Inhibit()
identified by the cookie.
The object path for the device that was added
Emitted when a device is added.
The object path for the device that was removed
Emitted when a device is removed.
The object path for the device that was changed
Emitted when a device is changed.
TRUE if flight mode has been enabled, otherwise FALSE
Emitted when flight mode is enabled or disabled.
The keycode emitted from the input device
Emitted when a rfkill key is pressed. The keycode is defined in
<linux/input.h>.
237KEY_BLUETOOTH
238KEY_WLAN
239KEY_UWB
246KEY_WIMAX
247KEY_RFKILL
The version the running daemon. e.g. 0.2.0
Whether the key control is enabled or not
./data/ofono-mock.xml 0000644 0000041 0000041 00000000616 13062464635 014761 0 ustar www-data www-data