indicator-network-prompt-0.1+14.04.20140305/ 0000755 0000152 0177776 00000000000 12305565112 020727 5 ustar pbuser nogroup 0000000 0000000 indicator-network-prompt-0.1+14.04.20140305/cmake/ 0000755 0000152 0177776 00000000000 12305565112 022007 5 ustar pbuser nogroup 0000000 0000000 indicator-network-prompt-0.1+14.04.20140305/cmake/COPYING-CMAKE-SCRIPTS 0000644 0000152 0177776 00000002457 12305564700 025017 0 ustar pbuser nogroup 0000000 0000000 Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
indicator-network-prompt-0.1+14.04.20140305/cmake/FindValgrind.cmake 0000644 0000152 0177776 00000001300 12305564700 025354 0 ustar pbuser nogroup 0000000 0000000
option(
ENABLE_MEMCHECK_OPTION
"If set to ON, enables automatic creation of memcheck targets"
OFF
)
find_program(
VALGRIND_PROGRAM
NAMES valgrind
)
if(VALGRIND_PROGRAM)
set(VALGRIND_PROGRAM_OPTIONS
"--suppressions=${CMAKE_SOURCE_DIR}/tests/data/valgrind.suppression"
"--error-exitcode=1"
"--leak-check=full"
"--gen-suppressions=all"
"--quiet"
)
endif()
find_package_handle_standard_args(
VALGRIND DEFAULT_MSG
VALGRIND_PROGRAM
)
function(add_valgrind_test NAME EXECUTABLE)
if(ENABLE_MEMCHECK_OPTION)
add_test(${NAME} ${VALGRIND_PROGRAM} ${VALGRIND_PROGRAM_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}")
else()
add_test(${NAME} ${EXECUTABLE})
endif()
endfunction()
indicator-network-prompt-0.1+14.04.20140305/cmake/FindGMock.cmake 0000644 0000152 0177776 00000000766 12305564700 024625 0 ustar pbuser nogroup 0000000 0000000 # Build with system gmock and embedded gtest
set (GMOCK_INCLUDE_DIRS "/usr/include/gmock/include" CACHE PATH "gmock source include directory")
set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
set (GTEST_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
set(GTEST_LIBRARIES gtest)
set(GTEST_MAIN_LIBRARIES gtest_main)
set(GMOCK_LIBRARIES gmock gmock_main)
indicator-network-prompt-0.1+14.04.20140305/cmake/Coverage.cmake 0000644 0000152 0177776 00000004222 12305564700 024546 0 ustar pbuser nogroup 0000000 0000000 if (CMAKE_BUILD_TYPE MATCHES coverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
if (NOT GCOVR_EXECUTABLE)
message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
else ()
message(STATUS "Gcovr found, can generate XML coverage info.")
add_custom_target (coverage-xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" --exclude="obj.*" -x -r "${CMAKE_SOURCE_DIR}"
--object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
endif()
find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
if (NOT LCOV_EXECUTABLE)
message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
else ()
if(NOT GENHTML_EXECUTABLE)
message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
else()
message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
add_custom_target (coverage-html
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND "${LCOV_EXECUTABLE}" --capture --output-file "${CMAKE_BINARY_DIR}/coverage.info" --no-checksum --directory "${CMAKE_BINARY_DIR}"
COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '/usr/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info"
COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '${CMAKE_BINARY_DIR}/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info"
COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '${CMAKE_SOURCE_DIR}/tests/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info"
COMMAND "${GENHTML_EXECUTABLE}" --prefix "${CMAKE_BINARY_DIR}" --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
)
endif()
endif()
endif()
indicator-network-prompt-0.1+14.04.20140305/tests/ 0000755 0000152 0177776 00000000000 12305565112 022071 5 ustar pbuser nogroup 0000000 0000000 indicator-network-prompt-0.1+14.04.20140305/tests/MenuPrinter.cpp 0000644 0000152 0177776 00000005170 12305564700 025052 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
class MenuPrinter: public QDBusMenuModel {
Q_OBJECT
public:
MenuPrinter(QObject* parent = 0) :
QDBusMenuModel(parent) {
setProperty("busType", DBusEnums::SessionBus);
setProperty("busName", QString::fromStdString(MenuExporter::DBUS_NAME));
setProperty("objectPath",
QString::fromStdString(MenuExporter::DBUS_PATH));
QObject::connect(this,
SIGNAL(rowsInserted(const QModelIndex&, int, int)),
SLOT(onModelChanged()));
}
private Q_SLOTS:
void onModelChanged() {
printModel(this);
qDebug() << "================";
}
private:
void printModel(QMenuModel* model, int indent = 0) {
int count = model->rowCount();
for (int i = 0; i < count; ++i) {
QModelIndex index = model->index(i, 0);
QString label = model->data(index, QMenuModel::Label).toString();
QVariantMap extra = model->data(index, QMenuModel::Extra).toMap();
{
QDebug debug(qDebug().nospace());
for (int j = 0; j < indent * 2; ++j)
debug << " ";
debug << " > " << label << " : " << extra;
}
printChilden(model, index, indent + 1);
}
}
void printChilden(QMenuModel* model, QModelIndex &index, int indent = 0) {
int children = model->rowCount(index);
for (int i = 0; i < children; ++i) {
QModelIndex childIndex(model->index(i, 0, index));
QString label(
model->data(childIndex, QMenuModel::Label).toString());
QVariantMap extra(
model->data(childIndex, QMenuModel::Extra).toMap());
{
QDebug debug(qDebug().nospace());
for (int j = 0; j < indent * 2; ++j)
debug << " ";
debug << " > " << label << " : " << extra;
}
printChilden(model, childIndex, indent + 1);
}
}
};
#include "MenuPrinter.moc"
int main(int argc, char** argv) {
QCoreApplication application(argc, argv);
MenuPrinter monitor;
monitor.start();
int result = application.exec();
monitor.stop();
return result;
}
indicator-network-prompt-0.1+14.04.20140305/tests/CMakeLists.txt 0000644 0000152 0177776 00000002140 12305564700 024630 0 ustar pbuser nogroup 0000000 0000000
set(CMAKE_AUTOMOC OFF)
include(FindGMock)
set(CMAKE_AUTOMOC ON)
find_package("Valgrind" REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${GMOCK_INCLUDE_DIRS})
include_directories(${GTEST_INCLUDE_DIRS})
add_definitions(-DMENU_PRINTER="${CMAKE_CURRENT_BINARY_DIR}/menu-printer")
add_definitions(-DEXPECTED_MENU_WITH_EXISTING_CONNECTION="${CMAKE_CURRENT_SOURCE_DIR}/data/expectedMenuWithExistingConnection.txt")
add_definitions(-DEXPECTED_MENU_WITHOUT_EXISTING_CONNECTION="${CMAKE_CURRENT_SOURCE_DIR}/data/expectedMenuWithoutExistingConnection.txt")
add_executable(
menu-printer
MenuPrinter.cpp
)
qt5_use_modules(
menu-printer
Core
)
target_link_libraries(
menu-printer
${QMENUMODEL_LIBRARIES}
indicator-network-prompt
)
set(
UNIT_TESTS_SRC
TestNetworkPrompt.cpp
main.cpp
)
add_executable(
unit-tests
${UNIT_TESTS_SRC}
)
qt5_use_modules(
unit-tests
Core
DBus
Test
)
target_link_libraries(
unit-tests
indicator-network-prompt
${QTDBUSMOCK_LIBRARIES}
${QTDBUSTEST_LIBRARIES}
${GTEST_LIBRARIES}
${GMOCK_LIBRARIES}
)
add_valgrind_test(
unit-tests
unit-tests
)
indicator-network-prompt-0.1+14.04.20140305/tests/main.cpp 0000644 0000152 0177776 00000002375 12305564700 023532 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#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);
InitGlib::init();
DBusTypes::registerMetaTypes();
DBusMock::registerMetaTypes();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
indicator-network-prompt-0.1+14.04.20140305/tests/TestNetworkPrompt.cpp 0000644 0000152 0177776 00000011541 12305564700 026274 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "qmenumodel/qdbusmenumodel.h"
using namespace std;
using namespace testing;
using namespace QtDBusTest;
using namespace QtDBusMock;
namespace {
class TestNetworkPrompt: public Test {
protected:
TestNetworkPrompt() :
dbusMock(dbusTestRunner), menuFactory(new MenuFactory()) {
dbusMock.registerNetworkManager();
dbusTestRunner.startServices();
menuPrinter.setProcessChannelMode(QProcess::MergedChannels);
menuPrinter.start(MENU_PRINTER);
menuPrinter.waitForStarted();
}
virtual ~TestNetworkPrompt() {
menuPrinter.terminate();
menuPrinter.waitForFinished();
}
DBusTestRunner dbusTestRunner;
DBusMock dbusMock;
QProcess networkManagerService;
shared_ptr menuFactory;
QProcess menuPrinter;
};
TEST_F(TestNetworkPrompt, ActivatesWithExistingConnection) {
OrgFreedesktopDBusPropertiesInterface properties(NM_DBUS_INTERFACE,
NM_DBUS_PATH, dbusTestRunner.systemConnection());
properties.Set(NM_DBUS_INTERFACE, "WirelessEnabled", QVariant(true)).waitForFinished();
properties.Set(NM_DBUS_INTERFACE, "State", QVariant(NM_STATE_DISCONNECTED)).waitForFinished();
NetworkManagerMockInterface &networkManager(
dbusMock.networkManagerInterface());
networkManager.AddWiFiDevice("device", "eth1", NM_DEVICE_STATE_DISCONNECTED).waitForFinished();
networkManager.AddAccessPoint(
"/org/freedesktop/NetworkManager/Devices/device", "ap", "ssid",
"11:22:33:44:55:66", 0, 0, 0, 's', 0).waitForFinished();
networkManager.AddWiFiConnection(
"/org/freedesktop/NetworkManager/Devices/device", "connection",
"the ssid", "wpa-psk").waitForFinished();
OrgFreedesktopDBusMockInterface &networkManagerMock(
dbusMock.mockInterface(NM_DBUS_SERVICE, NM_DBUS_PATH,
NM_DBUS_INTERFACE, QDBusConnection::SystemBus));
QSignalSpy networkManagerSpy(&networkManagerMock,
SIGNAL(MethodCalled(const QString &, const QVariantList &)));
NetworkPrompt networkPrompt(dbusTestRunner.sessionConnection(),
dbusTestRunner.systemConnection(), menuFactory);
networkPrompt.check();
networkManagerSpy.wait();
QList methodCalls(
networkManagerMock.GetMethodCalls("ActivateConnection"));
ASSERT_EQ(1, methodCalls.size());
const QVariantList &args(methodCalls.first().args());
ASSERT_EQ(3, args.size());
}
TEST_F(TestNetworkPrompt, ActivatesWithoutExistingConnection) {
OrgFreedesktopDBusPropertiesInterface properties(NM_DBUS_INTERFACE,
NM_DBUS_PATH, dbusTestRunner.systemConnection());
properties.Set(NM_DBUS_INTERFACE, "WirelessEnabled", QVariant(true)).waitForFinished();
properties.Set(NM_DBUS_INTERFACE, "State", QVariant(NM_STATE_DISCONNECTED)).waitForFinished();
NetworkManagerMockInterface &networkManager(
dbusMock.networkManagerInterface());
networkManager.AddWiFiDevice("device", "eth1", NM_DEVICE_STATE_DISCONNECTED).waitForFinished();
networkManager.AddAccessPoint(
"/org/freedesktop/NetworkManager/Devices/device", "ap1", "ssid1",
"11:22:33:44:55:66", 1, 0, 0, 's', 0).waitForFinished();
networkManager.AddAccessPoint(
"/org/freedesktop/NetworkManager/Devices/device", "ap2", "ssid2",
"22:33:44:55:66:77", 0, 0, 0, 's', 0).waitForFinished();
OrgFreedesktopDBusMockInterface &networkManagerMock(
dbusMock.mockInterface(NM_DBUS_SERVICE, NM_DBUS_PATH,
NM_DBUS_INTERFACE, QDBusConnection::SystemBus));
QSignalSpy networkManagerSpy(&networkManagerMock,
SIGNAL(MethodCalled(const QString &, const QVariantList &)));
NetworkPrompt networkPrompt(dbusTestRunner.sessionConnection(),
dbusTestRunner.systemConnection(), menuFactory);
networkPrompt.check();
networkManagerSpy.wait();
QList methodCalls(
networkManagerMock.GetMethodCalls("AddAndActivateConnection"));
ASSERT_EQ(1, methodCalls.size());
ASSERT_EQ(3, methodCalls.first().args().size());
}
} // namespace
indicator-network-prompt-0.1+14.04.20140305/tests/data/ 0000755 0000152 0177776 00000000000 12305565112 023002 5 ustar pbuser nogroup 0000000 0000000 indicator-network-prompt-0.1+14.04.20140305/tests/data/expectedMenuWithoutExistingConnection.txt 0000644 0000152 0177776 00000002657 12305564700 033324 0 ustar pbuser nogroup 0000000 0000000 > "Select wireless network" : QMap(("canfonical_wifi_device_path", QVariant(QString, "/org/freedesktop/NetworkManager/Devices/device") ) ( "canonical_children_display" , QVariant(QString, "inline") ) ( "canonical_type" , QVariant(QString, "unity.widget.systemsettings.tablet.sectiontitle") ) )
================
> "Select wireless network" : QMap(("canfonical_wifi_device_path", QVariant(QString, "/org/freedesktop/NetworkManager/Devices/device") ) ( "canonical_children_display" , QVariant(QString, "inline") ) ( "canonical_type" , QVariant(QString, "unity.widget.systemsettings.tablet.sectiontitle") ) )
> "ssid1" : QMap(("canonical_type", QVariant(QString, "unity.widgets.systemsettings.tablet.accesspoint") ) ( "canonical_wifi_ap_bssid" , QVariant(QString, "b'11:22:33:44:55:66'") ) ( "canonical_wifi_ap_dbus_path" , QVariant(QString, "/org/freedesktop/NetworkManager/AccessPoint/ap1") ) ( "canonical_wifi_ap_is_adhoc" , QVariant(bool, true) ) ( "canonical_wifi_ap_is_secure" , QVariant(bool, true) ) )
> "ssid2" : QMap(("canonical_type", QVariant(QString, "unity.widgets.systemsettings.tablet.accesspoint") ) ( "canonical_wifi_ap_bssid" , QVariant(QString, "b'22:33:44:55:66:77'") ) ( "canonical_wifi_ap_dbus_path" , QVariant(QString, "/org/freedesktop/NetworkManager/AccessPoint/ap2") ) ( "canonical_wifi_ap_is_adhoc" , QVariant(bool, false) ) ( "canonical_wifi_ap_is_secure" , QVariant(bool, true) ) )
================
indicator-network-prompt-0.1+14.04.20140305/tests/data/expectedMenuWithExistingConnection.txt 0000644 0000152 0177776 00000002023 12305564700 032557 0 ustar pbuser nogroup 0000000 0000000 > "Select wireless network" : QMap(("canfonical_wifi_device_path", QVariant(QString, "/org/freedesktop/NetworkManager/Devices/device") ) ( "canonical_children_display" , QVariant(QString, "inline") ) ( "canonical_type" , QVariant(QString, "unity.widget.systemsettings.tablet.sectiontitle") ) )
================
> "Select wireless network" : QMap(("canfonical_wifi_device_path", QVariant(QString, "/org/freedesktop/NetworkManager/Devices/device") ) ( "canonical_children_display" , QVariant(QString, "inline") ) ( "canonical_type" , QVariant(QString, "unity.widget.systemsettings.tablet.sectiontitle") ) )
> "ssid" : QMap(("canonical_type", QVariant(QString, "unity.widgets.systemsettings.tablet.accesspoint") ) ( "canonical_wifi_ap_bssid" , QVariant(QString, "b'11:22:33:44:55:66'") ) ( "canonical_wifi_ap_dbus_path" , QVariant(QString, "/org/freedesktop/NetworkManager/AccessPoint/ap") ) ( "canonical_wifi_ap_is_adhoc" , QVariant(bool, false) ) ( "canonical_wifi_ap_is_secure" , QVariant(bool, true) ) )
================
indicator-network-prompt-0.1+14.04.20140305/tests/data/valgrind.suppression 0000644 0000152 0177776 00000002442 12305564700 027130 0 ustar pbuser nogroup 0000000 0000000 {
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
}
###############################
# GObject rules
###############################
{
Memcheck:Leak
...
fun:g_type_register_static
}
{
Memcheck:Leak
...
fun:g_type_register_fundamental
}
{
Memcheck:Leak
...
fun:type_node_fundamental_new_W
}
{
Memcheck:Leak
...
fun:type_data_make_W
}
{
Memcheck:Leak
...
fun:g_type_add_interface_static
}
{
Memcheck:Leak
...
fun:type_iface_vtable_base_init_Wm
}
{
Memcheck:Leak
...
fun:g_dbus_interface_skeleton_class_intern_init
}
{
Memcheck:Leak
...
fun:g_signal_type_cclosure_new
}
{
Memcheck:Leak
fun:calloc
fun:g_malloc0
fun:g_type_class_ref
}
indicator-network-prompt-0.1+14.04.20140305/run.sh 0000755 0000152 0177776 00000000232 12305564700 022071 0 ustar pbuser nogroup 0000000 0000000 #!/bin/bash
set -e
SOURCEDIR="$PWD"
BRANCHNAME=`basename $SOURCEDIR`
BUILDDIR="$SOURCEDIR/../$BRANCHNAME-build"
$BUILDDIR/src/indicator-network-prompt
indicator-network-prompt-0.1+14.04.20140305/CMakeLists.txt 0000644 0000152 0177776 00000004532 12305564700 023475 0 ustar pbuser nogroup 0000000 0000000 project(indicator-network-prompt CXX)
cmake_minimum_required(VERSION 2.8.9)
set(API_VERSION 1)
set(ABI_VERSION 1)
set(GETTEXT_PACKAGE indicator-network-prompt)
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(NM REQUIRED NetworkManager REQUIRED)
include_directories(${NM_INCLUDE_DIRS})
pkg_check_modules(GLIBMM REQUIRED glibmm-2.4 REQUIRED)
include_directories(${GLIBMM_INCLUDE_DIRS})
pkg_check_modules(GIOMM REQUIRED giomm-2.4 REQUIRED)
include_directories(${GIOMM_INCLUDE_DIRS})
pkg_check_modules(QMENUMODEL REQUIRED qmenumodel REQUIRED)
include_directories(${QMENUMODEL_INCLUDE_DIRS})
pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1 REQUIRED)
include_directories(${QTDBUSTEST_INCLUDE_DIRS})
pkg_check_modules(QTDBUSMOCK REQUIRED libqtdbusmock-1 REQUIRED)
include_directories(${QTDBUSMOCK_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)
include(Coverage)
# 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
)
#set(DOXYFILE_SOURCE_DIR "include")
#set(DOXYFILE_EXTRA_SOURCES "doc")
#include(UseDoxygen)
#if(DOXYGEN_FOUND AND BUILD_DOXYGEN)
# install(
# DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html
# DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/libusermetrics-doc/
# )
#endif()
configure_file(
"${SOURCE_DIR}/config.h.in"
"${SOURCE_BINARY_DIR}/config.h"
)
#add_subdirectory("po")
add_subdirectory("src")
add_subdirectory("data")
enable_testing()
add_subdirectory(tests)
ADD_CUSTOM_TARGET(
check
${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure
)
indicator-network-prompt-0.1+14.04.20140305/run_on_device.sh 0000755 0000152 0177776 00000006667 12305564700 024126 0 ustar pbuser nogroup 0000000 0000000 #!/bin/sh
CODE_DIR=indicator-network-prompt
USER=phablet
USER_ID=32011
PASSWORD=phablet
PACKAGE=indicator-network-prompt
#BINARY=
TARGET_IP=${TARGET_IP-127.0.0.1}
TARGET_SSH_PORT=${TARGET_SSH_PORT-2222}
RUN_OPTIONS=
SETUP=false
GDB=false
SUDO="echo $PASSWORD | sudo -S"
NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
usage() {
echo "usage: run_on_device [OPTIONS]\n"
echo "Script to setup a build environment for the shell and sync build and run it on the device\n"
echo "OPTIONS:"
echo " -s, --setup Setup the build environment"
echo ""
echo "IMPORTANT:"
echo " * Make sure to have the networking and PPAs setup on the device beforehand (phablet-deploy-networking && phablet-ppa-fetch)."
echo " * Execute that script from a directory containing a branch the shell code."
exit 1
}
exec_with_ssh() {
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT "bash -lic \"$@\""
}
exec_with_adb() {
adb shell $@
}
adb_root() {
adb root
adb wait-for-device
}
install_ssh_key() {
ssh-keygen -R $TARGET_IP
HOME_DIR="/home/phablet"
adb push ~/.ssh/id_rsa.pub $HOME_DIR/.ssh/authorized_keys
adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh
adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh/authorized_keys
adb shell chmod 700 $HOME_DIR/.ssh
adb shell chmod 600 $HOME_DIR/.ssh/authorized_keys
}
setup_adb_forwarding() {
adb forward tcp:$TARGET_SSH_PORT tcp:22
adb forward tcp:$TARGET_DEBUG_PORT tcp:$TARGET_DEBUG_PORT
}
install_dependencies() {
exec_with_adb apt-get update
exec_with_adb apt-get -y install openssh-server
exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs
}
sync_code() {
[ -e .bzr ] && bzr export --uncommitted --format=dir /tmp/$CODE_DIR
[ -e .git ] && git checkout-index -a -f --prefix=/tmp/$CODE_DIR/
rsync -crlOzv --delete --exclude builddir -e "ssh -p $TARGET_SSH_PORT -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" /tmp/$CODE_DIR/ $USER@$TARGET_IP:$CODE_DIR/
rm -rf /tmp/$CODE_DIR
}
build() {
exec_with_ssh "[ $CODE_DIR/debian/control -nt indicator-network-prompt-build-deps*deb ] && $SUDO mk-build-deps --tool=\\\"apt-get -y --no-install-recommends\\\" --build-dep --install $CODE_DIR/debian/control"
exec_with_ssh PATH=/usr/lib/ccache:$PATH "cd $CODE_DIR/ && PATH=/usr/lib/ccache:$PATH ./build.sh"
}
run() {
exec_with_ssh "cd $CODE_DIR/ && ./run.sh $ARGS -- $RUN_OPTIONS"
}
set -- `getopt -n$0 -u -a --longoptions="setup,gdb,help" "sgpkh" "$@"`
# FIXME: giving incorrect arguments does not call usage and exit
while [ $# -gt 0 ]
do
case "$1" in
-s|--setup) SETUP=true;;
-g|--gdb) GDB=true;;
-h|--help) usage;;
--) shift;break;;
esac
shift
done
adb_root
[ "${TARGET_IP}" = "127.0.0.1" ] && setup_adb_forwarding
if [ "`adb shell 'grep -q Ubuntu /etc/lsb-release 2> /dev/null && echo -n FLIPPED'`" = "FLIPPED" ]; then
if [ "${TARGET_IP}" != "127.0.0.1" ]; then
echo "ERROR: Flipped image detected, adb over TCP/IP isn't supported, yet :/"
echo "Unset TARGET_IP and try again."
exit 2
fi
fi
if $SETUP; then
echo "Setting up environment for building shell.."
install_ssh_key
install_dependencies
sync_code
else
echo "Transferring code.."
sync_code
echo "Building.."
build
echo "Running.."
run
fi
indicator-network-prompt-0.1+14.04.20140305/build.sh 0000755 0000152 0177776 00000002706 12305564700 022374 0 ustar pbuser nogroup 0000000 0000000 #! /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 indicator-network-prompt. 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=NO \
-DCMAKE_INSTALL_PREFIX="$SOURCEDIR/../$BRANCHNAME-install"
$BUILD_COMMAND
)
indicator-network-prompt-0.1+14.04.20140305/src/ 0000755 0000152 0177776 00000000000 12305565112 021516 5 ustar pbuser nogroup 0000000 0000000 indicator-network-prompt-0.1+14.04.20140305/src/WiFiMenu.h 0000644 0000152 0177776 00000005300 12305564700 023352 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef WIFIMENU_H_
#define WIFIMENU_H_
#include
class MenuExporterPrivate;
class WiFiMenuPrivate;
class AccessPointPrivate;
class DevicePrivate;
class MenuFactory;
class MenuExporter;
class WiFiMenu;
class Device;
class AccessPoint;
typedef std::shared_ptr MenuFactoryPtr;
typedef std::shared_ptr MenuExporterPtr;
typedef std::shared_ptr WiFiMenuPtr;
typedef std::shared_ptr DevicePtr;
typedef std::shared_ptr AccessPointPtr;
class MenuFactory {
public:
explicit MenuFactory();
virtual ~MenuFactory();
virtual MenuExporterPtr newMenuExporter(WiFiMenuPtr menu) const;
virtual WiFiMenuPtr newWiFiMenu() const;
virtual DevicePtr newDevice() const;
virtual AccessPointPtr newAccessPoint() const;
};
class MenuExporter {
friend class MenuFactory;
protected:
explicit MenuExporter(WiFiMenuPtr menu);
public:
virtual ~MenuExporter();
static const std::string DBUS_PATH;
static const std::string DBUS_NAME;
protected:
std::unique_ptr d;
};
class WiFiMenu {
friend class MenuExporter;
friend class MenuExporterPrivate;
friend class MenuFactory;
protected:
explicit WiFiMenu();
public:
virtual ~WiFiMenu();
virtual void addDevice(DevicePtr device);
protected:
std::unique_ptr d;
};
class Device {
friend class WiFiMenu;
friend class MenuFactory;
protected:
explicit Device();
public:
virtual ~Device();
virtual void addAccessPoint(AccessPointPtr accessPoint);
virtual void setPath(const std::string &path);
protected:
std::unique_ptr d;
};
class AccessPoint {
friend class Device;
friend class MenuFactory;
protected:
explicit AccessPoint();
public:
virtual ~AccessPoint();
virtual void setSsid(const char *ssid);
virtual void setAdhoc(bool adhoc);
virtual void setSecure(bool secure);
virtual void setBssid(const std::string &bssid);
virtual void setPath(const std::string &path);
protected:
std::unique_ptr d;
};
#endif /* WIFIMENU_H_ */
indicator-network-prompt-0.1+14.04.20140305/src/CMakeLists.txt 0000644 0000152 0177776 00000002602 12305564700 024260 0 ustar pbuser nogroup 0000000 0000000
set(
INDICATOR_NETWORK_PROMPT_SOURCES
NetworkPrompt.cpp
InitGlib.cpp
WiFiMenu.cpp
)
set_source_files_properties(
"${DATA_DIR}/nm-device.xml"
"${DATA_DIR}/nm-device-wifi.xml"
"${DATA_DIR}/nm-access-point.xml"
PROPERTIES
NO_NAMESPACE YES
)
set_source_files_properties(
"${DATA_DIR}/nm-manager.xml"
PROPERTIES
NO_NAMESPACE YES
INCLUDE "DBusTypes.h"
)
qt5_add_dbus_interface(
INDICATOR_NETWORK_PROMPT_SOURCES
"${DATA_DIR}/nm-manager.xml"
NetworkManagerInterface
)
qt5_add_dbus_interface(
INDICATOR_NETWORK_PROMPT_SOURCES
"${DATA_DIR}/nm-device.xml"
NetworkManagerDeviceInterface
)
qt5_add_dbus_interface(
INDICATOR_NETWORK_PROMPT_SOURCES
"${DATA_DIR}/nm-device-wifi.xml"
NetworkManagerDeviceWirelessInterface
)
qt5_add_dbus_interface(
INDICATOR_NETWORK_PROMPT_SOURCES
"${DATA_DIR}/nm-access-point.xml"
NetworkManagerAccessPointInterface
)
add_library(
indicator-network-prompt
STATIC
${INDICATOR_NETWORK_PROMPT_SOURCES}
)
qt5_use_modules(
indicator-network-prompt
Core
DBus
)
target_link_libraries(
indicator-network-prompt
${GLIBMM_LIBRARIES}
${GIOMM_LIBRARIES}
)
add_executable(
indicator-network-prompt-bin
main.cpp
)
set_target_properties(
indicator-network-prompt-bin
PROPERTIES
OUTPUT_NAME indicator-network-prompt
)
qt5_use_modules(
indicator-network-prompt-bin
Core
)
target_link_libraries(
indicator-network-prompt-bin
indicator-network-prompt
)
indicator-network-prompt-0.1+14.04.20140305/src/InitGlib.h 0000644 0000152 0177776 00000001470 12305564700 023374 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef INITGLIB_H_
#define INITGLIB_H_
class InitGlib {
public:
static void init();
};
#endif /* INITGLIB_H_ */
indicator-network-prompt-0.1+14.04.20140305/src/InitGlib.cpp 0000644 0000152 0177776 00000001434 12305564700 023727 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
void InitGlib::init() {
Gio::init();
}
indicator-network-prompt-0.1+14.04.20140305/src/DBusTypes.h 0000644 0000152 0177776 00000002057 12305564700 023557 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef DBUSTYPES_H_
#define DBUSTYPES_H_
#include
#include
typedef QMap QVariantDictMap;
Q_DECLARE_METATYPE(QVariantDictMap)
class DBusTypes {
public:
static void registerMetaTypes() {
qRegisterMetaType("QVariantDictMap");
qDBusRegisterMetaType();
}
};
#endif /* DBUSTYPES_H_ */
indicator-network-prompt-0.1+14.04.20140305/src/config.h.in 0000644 0000152 0177776 00000001514 12305564700 023544 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#ifndef CONFIG_H_
#define CONFIG_H_
#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
#define LOCALE_DIR "@LOCALE_DIR@"
#endif // CONFIG_H_
indicator-network-prompt-0.1+14.04.20140305/src/main.cpp 0000644 0000152 0177776 00000002402 12305564700 023146 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
#include
int main(int argc, char *argv[]) {
QCoreApplication application(argc, argv);
InitGlib::init();
DBusTypes::registerMetaTypes();
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
textdomain(GETTEXT_PACKAGE);
NetworkPrompt networkPrompt(QDBusConnection::sessionBus(),
QDBusConnection::systemBus(), MenuFactoryPtr(new MenuFactory()));
networkPrompt.check();
return 0;
}
indicator-network-prompt-0.1+14.04.20140305/src/WiFiMenu.cpp 0000644 0000152 0177776 00000013352 12305564700 023713 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*
* Author: Pete Woods
*/
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace Glib;
using namespace Gio;
using namespace Gio::DBus;
typedef Variant StringVariant;
class WiFiMenuPrivate {
public:
WiFiMenuPrivate() :
m_menu(Menu::create()) {
}
RefPtr