content-hub-0.0+14.04.20140415/0000755000015301777760000000000012323326474016203 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/cmake/0000755000015301777760000000000012323326474017263 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/cmake/EnableCoverageReport.cmake0000644000015301777760000001562112323326002024313 0ustar pbusernogroup00000000000000# - Creates a special coverage build type and target on GCC. # # Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target # for selected targets. Optional arguments to this function are used to filter # unwanted results using globbing expressions. Moreover targets with tests for # the source code can be specified to trigger regenerating the report if the # test has changed # # ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...]) # # To generate a coverage report first build the project with # CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage. # # The coverage report is based on gcov. Depending on the availability of lcov # a HTML report will be generated and/or an XML report of gcovr is found. # The generated coverage target executes all found solutions. Special targets # exist to create e.g. only the xml report: coverage-xml. # # Copyright (C) 2010 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program 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 General Public License for more details. # INCLUDE(ParseArguments) FIND_PACKAGE(Lcov) FIND_PACKAGE(gcovr) FUNCTION(ENABLE_COVERAGE_REPORT) # argument parsing PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN}) SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info") SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info") SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport") SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml") SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake") # decide if there is any tool to create coverage data SET(TOOL_FOUND FALSE) IF(LCOV_FOUND OR GCOVR_FOUND) SET(TOOL_FOUND TRUE) ENDIF() IF(NOT TOOL_FOUND) MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.") ENDIF() STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE) IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage") MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}") # create coverage build type SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE) SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE) SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE) # instrument targets SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage LINK_FLAGS --coverage) # html report IF (LCOV_FOUND) MESSAGE(STATUS "Enabling HTML coverage report") # set up coverage target ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE} COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Collecting coverage data" DEPENDS ${ARG_TARGETS} ${ARG_TESTS} VERBATIM) # filter unwanted stuff LIST(LENGTH ARG_FILTER FILTER_LENGTH) IF(${FILTER_LENGTH} GREATER 0) SET(FILTER COMMAND ${LCOV_EXECUTABLE}) FOREACH(F ${ARG_FILTER}) SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F}) ENDFOREACH() SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE}) ELSE() SET(FILTER "") ENDIF() ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE} COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE} ${FILTER} DEPENDS ${COVERAGE_RAW_FILE} COMMENT "Filtering recorded coverage data for project-relevant entries" VERBATIM) ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR} COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE} DEPENDS ${COVERAGE_FILTERED_FILE} COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}" VERBATIM) ADD_CUSTOM_TARGET(coverage-html DEPENDS ${COVERAGE_REPORT_DIR}) ENDIF() # xml coverage report IF(GCOVR_FOUND) MESSAGE(STATUS "Enabling XML coverage report") # gcovr cannot write directly to a file so the execution needs to # be wrapped in a cmake file that generates the file output FILE(WRITE ${COVERAGE_XML_COMMAND_FILE} "SET(ENV{LANG} en)\n") FILE(APPEND ${COVERAGE_XML_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" --exclude=3rd_party.* --exclude=tests.* --exclude=obj-.* --exclude=cmake.* --exclude=include.mir_test.* --exclude=include.mir_test_doubles.* --exclude=include.mir_test_framework.* -c \"${CMAKE_GCOV}\" -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n") ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE} COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE} COMMENT "Generating coverage XML report" VERBATIM) ADD_CUSTOM_TARGET(coverage-xml DEPENDS ${COVERAGE_XML_FILE}) ENDIF() # provide a global coverage target executing both steps if available SET(GLOBAL_DEPENDS "") IF(LCOV_FOUND) LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR}) ENDIF() IF(GCOVR_FOUND) LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE}) ENDIF() IF(LCOV_FOUND OR GCOVR_FOUND) ADD_CUSTOM_TARGET(coverage DEPENDS ${GLOBAL_DEPENDS}) ENDIF() ENDIF() ENDFUNCTION() content-hub-0.0+14.04.20140415/cmake/Findgcovr.cmake0000644000015301777760000000170212323326002022171 0ustar pbusernogroup00000000000000# - Find gcovr scrip # Will define: # # GCOVR_EXECUTABLE - the gcovr script # # Uses: # # GCOVR_ROOT - root to search for the script # # Copyright (C) 2011 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program 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 General Public License for more details. # INCLUDE(FindPackageHandleStandardArgs) FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE) # only visible in advanced view MARK_AS_ADVANCED(GCOVR_EXECUTABLE) content-hub-0.0+14.04.20140415/cmake/ParseArguments.cmake0000644000015301777760000000340612323326002023213 0ustar pbusernogroup00000000000000# Parse arguments passed to a function into several lists separated by # upper-case identifiers and options that do not have an associated list e.g.: # # SET(arguments # hello OPTION3 world # LIST3 foo bar # OPTION2 # LIST1 fuz baz # ) # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments}) # # results in 7 distinct variables: # * ARG_DEFAULT_ARGS: hello;world # * ARG_LIST1: fuz;baz # * ARG_LIST2: # * ARG_LIST3: foo;bar # * ARG_OPTION1: FALSE # * ARG_OPTION2: TRUE # * ARG_OPTION3: TRUE # # taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments MACRO(PARSE_ARGUMENTS prefix arg_names option_names) SET(DEFAULT_ARGS) FOREACH(arg_name ${arg_names}) SET(${prefix}_${arg_name}) ENDFOREACH(arg_name) FOREACH(option ${option_names}) SET(${prefix}_${option} FALSE) ENDFOREACH(option) SET(current_arg_name DEFAULT_ARGS) SET(current_arg_list) FOREACH(arg ${ARGN}) SET(larg_names ${arg_names}) LIST(FIND larg_names "${arg}" is_arg_name) IF (is_arg_name GREATER -1) SET(${prefix}_${current_arg_name} ${current_arg_list}) SET(current_arg_name ${arg}) SET(current_arg_list) ELSE (is_arg_name GREATER -1) SET(loption_names ${option_names}) LIST(FIND loption_names "${arg}" is_option) IF (is_option GREATER -1) SET(${prefix}_${arg} TRUE) ELSE (is_option GREATER -1) SET(current_arg_list ${current_arg_list} ${arg}) ENDIF (is_option GREATER -1) ENDIF (is_arg_name GREATER -1) ENDFOREACH(arg) SET(${prefix}_${current_arg_name} ${current_arg_list}) ENDMACRO(PARSE_ARGUMENTS) content-hub-0.0+14.04.20140415/cmake/GSettings.cmake0000644000015301777760000000371512323326002022165 0ustar pbusernogroup00000000000000# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them. option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" ${LOCAL_INSTALL}) option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" ${GSETTINGS_LOCALINSTALL}) if(GSETTINGS_LOCALINSTALL) message(STATUS "GSettings schemas will be installed locally.") endif() if(GSETTINGS_COMPILE) message(STATUS "GSettings shemas will be compiled.") endif() macro(add_schema SCHEMA_NAME) set(PKG_CONFIG_EXECUTABLE pkg-config) # Have an option to not install the schema into where GLib is if (GSETTINGS_LOCALINSTALL) SET (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/") else (GSETTINGS_LOCALINSTALL) execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/") endif (GSETTINGS_LOCALINSTALL) # Run the validator and error if it fails execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE) if (_schemas_invalid) message (SEND_ERROR "Schema validation error: ${_schemas_invalid}") endif (_schemas_invalid) # Actually install and recomple schemas message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}") install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL) if (GSETTINGS_COMPILE) install (CODE "message (STATUS \"Compiling GSettings schemas\")") install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})") endif () endmacro() content-hub-0.0+14.04.20140415/examples/0000755000015301777760000000000012323326474020021 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/examples/importer/0000755000015301777760000000000012323326474021662 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/examples/importer/example.h0000644000015301777760000000174512323326002023460 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #ifndef EXAMPLE_H #define EXAMPLE_H #include #include "exampleimporter.h" class Example : public QObject { Q_OBJECT public: explicit Example(QObject *parent = 0); void create_import(); private: ExampleImporter *m_importer; cuc::Transfer *m_transfer; }; #endif // EXAMPLE_H content-hub-0.0+14.04.20140415/examples/importer/exampleimporter.cpp0000644000015301777760000000264412323326002025574 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include "exampleimporter.h" ExampleImporter::ExampleImporter() { auto hub = cuc::Hub::Client::instance(); hub->register_import_export_handler(this); } void ExampleImporter::handle_import(cuc::Transfer *transfer) { qDebug() << Q_FUNC_INFO; auto items = transfer->collect(); qDebug() << Q_FUNC_INFO << "Items:" << items.count(); Q_FOREACH(cuc::Item item, items) qDebug() << Q_FUNC_INFO << "Item:" << item.url(); transfer->finalize(); } void ExampleImporter::handle_export(cuc::Transfer *transfer) { qDebug() << Q_FUNC_INFO << "not implemented"; Q_UNUSED(transfer); } void ExampleImporter::handle_share(cuc::Transfer *transfer) { qDebug() << Q_FUNC_INFO << "not implemented"; Q_UNUSED(transfer); } content-hub-0.0+14.04.20140415/examples/importer/exampleimporter.h0000644000015301777760000000233412323326002025235 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #ifndef EXAMPLEIMPORTER_H #define EXAMPLEIMPORTER_H #include #include #include #include #include namespace cuc = com::ubuntu::content; class ExampleImporter : public cuc::ImportExportHandler { Q_OBJECT public: ExampleImporter(); Q_INVOKABLE void handle_import(cuc::Transfer*); Q_INVOKABLE void handle_export(cuc::Transfer*); Q_INVOKABLE void handle_share(cuc::Transfer*); }; #endif // EXAMPLEIMPORTER_H content-hub-0.0+14.04.20140415/examples/importer/example.cpp0000644000015301777760000000265712323326002024016 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include "example.h" #include Example::Example(QObject *parent) : QObject(parent), m_importer(new ExampleImporter()) { } void Example::create_import() { auto hub = cuc::Hub::Client::instance(); auto peer = hub->default_source_for_type(cuc::Type::Known::pictures()); qDebug() << Q_FUNC_INFO << "PEER: " << peer.name(); m_transfer = hub->create_import_from_peer(peer); /* Uncommit this for persistent storage auto store = hub->store_for_scope_and_type(cuc::Scope::app, cuc::Type::Known::pictures()); qDebug() << Q_FUNC_INFO << "STORE:" << store->uri(); m_transfer->setStore(store); */ m_transfer->setSelectionType(cuc::Transfer::SelectionType::multiple); m_transfer->start(); } content-hub-0.0+14.04.20140415/examples/importer/CMakeLists.txt0000644000015301777760000000167412323326002024415 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Ken VanDine include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable( importer importer.cpp exampleimporter.cpp example.cpp ) qt5_use_modules(importer Core Gui DBus) set_target_properties( importer PROPERTIES AUTOMOC TRUE ) target_link_libraries( importer content-hub ) content-hub-0.0+14.04.20140415/examples/importer/importer.cpp0000644000015301777760000000251212323326002024212 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include #include #include "example.h" namespace cuc = com::ubuntu::content; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); Example *e = new Example(); QString peerName; if (a.arguments().size() > 1) peerName = a.arguments().at(1); if (!peerName.isEmpty()) { qDebug() << peerName; auto hub = cuc::Hub::Client::instance(); auto peer = cuc::Peer{peerName}; qDebug() << Q_FUNC_INFO << "PEER: " << peer.id(); auto transfer = hub->create_import_from_peer(peer); transfer->start(); } Q_UNUSED(e); return a.exec(); } content-hub-0.0+14.04.20140415/examples/exporter/0000755000015301777760000000000012323326474021671 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/examples/exporter/exampleexporter.h0000644000015301777760000000235712323326002025260 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #ifndef EXAMPLEEXPORTER_H #define EXAMPLEEXPORTER_H #include #include #include #include #include namespace cuc = com::ubuntu::content; class ExampleExporter : public cuc::ImportExportHandler { Q_OBJECT public: ExampleExporter(); public slots: Q_INVOKABLE void handle_import(cuc::Transfer*); Q_INVOKABLE void handle_export(cuc::Transfer*); Q_INVOKABLE void handle_share(cuc::Transfer*); }; #endif // EXAMPLEEXPORTER_H content-hub-0.0+14.04.20140415/examples/exporter/exporter.cpp0000644000015301777760000000264412323326002024236 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include #include #include "exampleexporter.h" namespace cuc = com::ubuntu::content; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); if (qgetenv("APP_ID").isEmpty()) { qputenv("APP_ID", "gallery-app"); } ExampleExporter exporter; QString peerName; if (a.arguments().size() > 1) peerName = a.arguments().at(1); if (!peerName.isEmpty()) { qDebug() << peerName; auto hub = cuc::Hub::Client::instance(); auto peer = cuc::Peer{peerName}; qDebug() << Q_FUNC_INFO << "PEER: " << peer.id(); auto transfer = hub->create_export_to_peer(peer); exporter.handle_export(transfer); } return a.exec(); } content-hub-0.0+14.04.20140415/examples/exporter/CMakeLists.txt0000644000015301777760000000165612323326002024424 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Ken VanDine include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable( exporter exporter.cpp exampleexporter.cpp ) qt5_use_modules(exporter Core Gui DBus) set_target_properties( exporter PROPERTIES AUTOMOC TRUE ) target_link_libraries( exporter content-hub ) content-hub-0.0+14.04.20140415/examples/exporter/exampleexporter.cpp0000644000015301777760000000345212323326002025610 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include "exampleexporter.h" ExampleExporter::ExampleExporter() { auto hub = cuc::Hub::Client::instance(); hub->register_import_export_handler(this); } void ExampleExporter::handle_import(cuc::Transfer *transfer) { qDebug() << Q_FUNC_INFO << "not implemented"; Q_UNUSED(transfer); } void ExampleExporter::handle_export(cuc::Transfer *transfer) { qDebug() << Q_FUNC_INFO; if (transfer == nullptr) { qDebug() << Q_FUNC_INFO << "Transfer null"; return; } if (transfer->selectionType() == cuc::Transfer::SelectionType::single) qDebug() << Q_FUNC_INFO << "selectionType: single"; else if (transfer->selectionType() == cuc::Transfer::SelectionType::multiple) qDebug() << Q_FUNC_INFO << "selectionType: multiple"; QVector items; items << cuc::Item(QUrl("file:///tmp/test1")); items << cuc::Item(QUrl("file:///tmp/test2")); transfer->charge(items); qDebug() << Q_FUNC_INFO << "Items:" << items.count(); } void ExampleExporter::handle_share(cuc::Transfer *transfer) { qDebug() << Q_FUNC_INFO << "not implemented"; Q_UNUSED(transfer); } content-hub-0.0+14.04.20140415/examples/picker-qml/0000755000015301777760000000000012323326474022065 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/examples/picker-qml/picker.qml0000644000015301777760000000734112323326002024045 0ustar pbusernogroup00000000000000import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Components.ListItems 0.1 as ListItem import Ubuntu.Components.Popups 0.1 import Ubuntu.Content 0.1 MainView { id: mainView applicationName: "picker-qml" width: units.gu(100) height: units.gu(75) PageStack { id: pageStack Component.onCompleted: pageStack.push(root) Page { id: root title: i18n.tr("Peer Picker Example") visible: false property list importItems property var activeTransfer property list peers Column { anchors.fill: parent ListItem.Standard { id: peerListHeader anchors { left: parent.left right: parent.right } text: i18n.tr("Sources") control: Button { text: i18n.tr("Select source") onClicked: { pageStack.push(picker); } } } ListItem.Header { id: titleItem anchors { left: parent.left right: parent.right } text: i18n.tr("Results") } GridView { id: resultList anchors { left: parent.left right: parent.right } height: childrenRect.height cellWidth: units.gu(20) cellHeight: cellWidth model: root.importItems delegate: Item { id: result height: units.gu(19) width: height UbuntuShape { width: parent.width height: width image: Image { id: image source: url sourceSize.width: width sourceSize.height: height height: parent.height width: height fillMode: Image.PreserveAspectFit smooth: true } } } } } ContentTransferHint { anchors.fill: root activeTransfer: root.activeTransfer } Connections { target: root.activeTransfer onStateChanged: { console.log("StateChanged: " + root.activeTransfer.state); if (root.activeTransfer.state === ContentTransfer.Charged) root.importItems = root.activeTransfer.items; } } } Page { id: picker visible: false ContentPeerPicker { visible: parent.visible // Type of handler: Source, Destination, or Share handler: ContentHandler.Source // well know content type contentType: ContentType.Pictures onPeerSelected: { root.activeTransfer = peer.request(); pageStack.pop(); } onCancelPressed: { pageStack.pop(); } } } } } content-hub-0.0+14.04.20140415/examples/import-qml/0000755000015301777760000000000012323326474022122 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/examples/import-qml/import.qml0000644000015301777760000000722612323326002024141 0ustar pbusernogroup00000000000000import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Components.ListItems 0.1 as ListItem import Ubuntu.Content 0.1 MainView { id: root applicationName: "import-qml" width: 300 height: 200 property list importItems property var activeTransfer ContentPeer { id: picSource // well know content type contentType: ContentType.Pictures // Type of handler: Source, Destination, or Share handler: ContentHandler.Source // Optional appId, if this isn't specified the hub will use the default //appId: "" } // Optional store to use for persistent storage of content ContentStore { id: appStore scope: ContentScope.App } // Provides a list suitable for use as a model ContentPeerModel { id: picSources // Type of handler: Source, Destination, or Share handler: ContentHandler.Source // well know content type contentType: ContentType.Pictures } ListView { id: peerList anchors { left: parent.left right: parent.right top: importButtons.bottom } height: childrenRect.height model: picSources.peers delegate: ListItem.Standard { text: modelData.name control: Button { text: "Import" onClicked: { // Request the transfer, it needs to be created and dispatched from the hub activeTransfer = modelData.request(); } } } } ListItem.Empty { id: importButtons Button { anchors { left: parent.left margins: units.gu(2) } text: "Import from default" onClicked: { // Request the transfer, it needs to be created and dispatched from the hub // Specify a location to use for permanent storage activeTransfer = picSource.request(appStore); } } Button { anchors { right: parent.right margins: units.gu(2) } text: "Finalize import" enabled: activeTransfer.state === ContentTransfer.Collected onClicked: activeTransfer.finalize() } } ListView { id: resultList anchors { left: parent.left right: parent.right top: peerList.bottom } height: childrenRect.height model: importItems delegate: ListItem.Empty { id: result height: 128 UbuntuShape { anchors.horizontalCenter: parent.horizontalCenter width: image.width height: image.height image: Image { id: image source: url height: result.height fillMode: Image.PreserveAspectFit smooth: true } } } } // Provides overlay showing another app is being used to complete the request // formerly named ContentImportHint ContentTransferHint { anchors.fill: parent activeTransfer: activeTransfer } Connections { target: activeTransfer onStateChanged: { console.log("StateChanged: " + activeTransfer.state); if (activeTransfer.state === ContentTransfer.Charged) importItems = activeTransfer.items; } } } content-hub-0.0+14.04.20140415/examples/export-qml/0000755000015301777760000000000012323326474022131 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/examples/export-qml/photo-preview-selected-overlay.png0000644000015301777760000001133712323326002030704 0ustar pbusernogroup00000000000000PNG  IHDRZë́ztEXtSoftwareAdobe ImageReadyqe<$iTXtXML:com.adobe.xmp QIDATxpgǟw~kIrVRQi[ TTLqN;tX/ lLE() ?\~@ٽ.y].}{y}(A?Eγg!DruI{1[1sU~.)8.Ḁ88cF #d|]__s` Ұ Ћ{8q(h/5hMV_%8p\:?H-9@= y.?7qdJhbݭVkkC!4[2&j/ui)<6¾:|]e>lcg@Ax/h-Q̠@Ю+[A:A_FNj89\NuҠ5`66وYVϮHؠg,D`6}|~Bz*Y +cF x͛y Y Km6Ce"jûWx hKp',EvD>M=۔`tجLL.UOɐzt(o5rS 4n:rmv2,R8F6(Eгld6ɫڀ]H9vy[-^*C^㿨[u+$c&Hs8&.ܳ7 8wuX`g2gN/Y$飳oqpKW6U*Zg$yYuhtT[Mh,;tV*[s!oW + &/RYs;i>y)So;e ͣ kH6< ]/?5w/χ䓯gj#_A;CTh Hnj#@$O: M@聁W )s7€FTƓZ 諣!F7H(5lf. mJG2؜дy/OuVⷩD2̕ќsBӖ! Y`3{ٜf=dNF;A7ߥFB; V9V2wʕ+r(jQɭpuZzCК{{{;ʥ){K v=>rKڶ`@E{ 2o#]MGnJ:֑H$y|$7N |qV"hۑ# 1Ńr%дq$N_lNJh%}rSt] Hnك,G׳JJo"(ŕX 1MuO^mN>B21lATvlm!}[I@V @l +ݹ֡sKxAIbK!ECZSḍғB=8qVBS/'u>lţu(ȁb. lD{vLNIR.Ç.c@Ƹ;Aςnf#93ul?e={ *8GyHvP i)^am*?z_#\z6*A`= h/ ׏L$bO{ T& L.ZjW7p=f#i+ $8Zͼ$PYHA#7o;vl@if^9my=mDlP,gMJ{22wkW.\^:ihCc5;M .oXhP1Fpݺu˖-{ LPwmZ rT & &.eN7n\̝;wQCCô`0X}3`4eGoc ]|%K>mڴSNWgHMLhEt:ŌٻYehhii6F/o5kI&EmpIXhtZf9j̙3뮛o曧džeB|}zCLAvhհ .dyKj̙?9}Ĕ)SJT{ 1uD` r63Eh M㹀){O h%d8qbt\.W;y:ԄpG`V - wJ@qu?ko øo.Q_gT}K5?f!hҠ .p̭jbT'/^CBYuM7$1wB 4hڬh" 2 Z"@'-mnZA˦!Qy;i-RV\@X_纤1L D@͓*,hQ^t 7(kNe&ZbBd&(AQ<Ȭ8@\T, cA,D_Тo sxiu˛%zqOAtuHF#IENDB`content-hub-0.0+14.04.20140415/examples/export-qml/app-exporter.qml0000644000015301777760000001471712323326002025267 0ustar pbusernogroup00000000000000import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Components.Popups 0.1 import Ubuntu.Components.ListItems 0.1 as ListItem import Ubuntu.Content 0.1 MainView { id: root applicationName: "app-exporter" width: units.gu(50) height: units.gu(60) property bool pickMode: activeTransfer.state === ContentTransfer.InProgress property var selectedItems: [] property var activeTransfer ListModel { id: images ListElement { src: "file:///usr/share/icons/hicolor/128x128/apps/ubuntuone-music.png" } ListElement { src: "file:///usr/share/icons/hicolor/128x128/apps/ubuntuone-music.png" } ListElement { src: "file:///usr/share/icons/hicolor/128x128/apps/ubuntuone-music.png" } ListElement { src: "file:///usr/share/icons/hicolor/128x128/apps/ubuntuone-music.png" } } GridView { anchors.fill: parent model: images cellWidth: 128 cellHeight: 128 delegate: itemDelegate } Component { id: resultComponent ContentItem {} } Component { id: itemDelegate Item { width: 128 height: 128 property bool isSelected: false UbuntuShape { width: parent.width height: width image: Image { id: image source: src height: parent.width width: height fillMode: Image.PreserveAspectFit smooth: true } MouseArea { anchors.fill: parent enabled: pickMode onClicked: { var shouldAdd = true; for (var i = 0; i < selectedItems.length; i++) { console.log("item: ", selectedItems[i]); if (selectedItems[i] === src) { selectedItems.pop(i); shouldAdd = false; isSelected = false; } } if (shouldAdd) { selectedItems.push(src); isSelected = true; } } } Image { id: selectionTick anchors.right: parent.right anchors.top: parent.top width: units.gu(5) height: units.gu(5) visible: isSelected source: "photo-preview-selected-overlay.png" } MouseArea { anchors.fill: parent enabled: !pickMode onClicked: { actPop.show(); } } ActionSelectionPopover { id: actPop delegate: ListItem.Standard { text: action.text } contentWidth: childrenRect.width actions: ActionList { Action { text: "Open with..." onTriggered: { print(text + ": " + src); activeTransfer = picDest.request(); activeTransfer.items = [ resultComponent.createObject(root, {"url": src}) ]; activeTransfer.state = ContentTransfer.Charged; actPop.hide(); } } Action { text: "Share" onTriggered: { print(text + ": " + src); activeTransfer = picShare.request(); activeTransfer.items = [ resultComponent.createObject(root, {"url": src}) ]; activeTransfer.state = ContentTransfer.Charged; actPop.hide(); } } } } } } } ContentPeer { id: picDest // well know content type contentType: ContentType.Pictures // Type of handler: Source, Destination, or Share handler: ContentHandler.Destination // Optional appId, if this isn't specified the hub will use the default //appId: "" } ContentPeer { id: picShare // well know content type contentType: ContentType.Pictures // Type of handler: Source, Destination, or Share handler: ContentHandler.Share // Optional appId, if this isn't specified the hub will use the default appId: "pkg_app_version" } // Provides overlay showing another app is being used to complete the request // formerly named ContentImportHint ContentTransferHint { anchors.fill: parent activeTransfer: activeTransfer } Connections { target: ContentHub onExportRequested: { activeTransfer = transfer } } ListItem.Empty { id: pickerButtons anchors { left: parent.left right: parent.right bottom: parent.bottom margins: units.gu(2) } visible: pickMode Button { anchors { left: parent.left bottom: parent.bottom margins: units.gu(2) } text: "Cancel" onClicked: activeTransfer.state = ContentTransfer.Aborted; } Button { anchors { right: parent.right bottom: parent.bottom margins: units.gu(2) } text: "Select" onClicked: { var results = []; for (var i = 0; i < selectedItems.length; i++) results.push(resultComponent.createObject(root, {"url": selectedItems[i]})); if (results.length > 0) activeTransfer.items = results; } } } } content-hub-0.0+14.04.20140415/examples/export-qml/export.qml0000644000015301777760000000314612323326002024154 0ustar pbusernogroup00000000000000import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Content 0.1 MainView { id: root width: 300 height: 200 property bool pickMode: activeTransfer.state === ContentTransfer.InProgress property list selectedItems property var activeTransfer Button { id: button1 anchors.top: parent.top anchors.left: parent.left enabled: pickMode text: "Return URL1" onClicked: { selectedItems = [ resultComponent.createObject(root, {"url": "file:///picture_1.jpg"}) ]; activeTransfer.items = selectedItems; } } Button { id: button2 anchors.top: parent.top anchors.right: parent.right enabled: pickMode text: "Return Url2" onClicked: { selectedItems.push(resultComponent.createObject(root, {"url": "file:///picture_1.jpg"})); selectedItems.push(resultComponent.createObject(root, {"url": "file:///picture_2.jpg"})); console.log(selectedItems[0].url + "/" + selectedItems[1].url) activeTransfer.items = selectedItems; } } Button { id: buttonAbort anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter enabled: pickMode text: "Cancel" onClicked: { activeTransfer.state = ContentTransfer.Aborted; } } Component { id: resultComponent ContentItem {} } Connections { target: ContentHub onExportRequested: { activeTransfer = transfer } } } content-hub-0.0+14.04.20140415/examples/CMakeLists.txt0000644000015301777760000000131712323326002022546 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Ken VanDine add_subdirectory(importer) add_subdirectory(exporter) content-hub-0.0+14.04.20140415/COPYING.GPL0000644000015301777760000010437412323326002017653 0ustar pbusernogroup00000000000000 GNU 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. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 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 . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . content-hub-0.0+14.04.20140415/tests/0000755000015301777760000000000012323326474017345 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/tests/cross_process_sync.h0000644000015301777760000000310312323326002023421 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef CROSS_PROCESS_SYNC_H_ #define CROSS_PROCESS_SYNC_H_ #include #include #include namespace test { struct CrossProcessSync { static const int read_fd = 0; static const int write_fd = 1; CrossProcessSync() { if (pipe(fds) < 0) throw std::runtime_error(strerror(errno)); } ~CrossProcessSync() noexcept { ::close(fds[0]); ::close(fds[1]); } void signal_ready() { int value = 42; if (!write(fds[write_fd], std::addressof(value), sizeof(value))) throw std::runtime_error(::strerror(errno)); } void wait_for_signal_ready() const { int value; if (!read(fds[read_fd], std::addressof(value), sizeof(value))) throw std::runtime_error(::strerror(errno)); } int fds[2]; }; } #endif // CROSS_PROCESS_SYNC_H_ content-hub-0.0+14.04.20140415/tests/CMakeLists.txt0000644000015301777760000000245712323326002022100 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss # Build with system gmock and embedded gtest set (GMOCK_INCLUDE_DIR "/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_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") include_directories ( ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content ${UPSTART_LAUNCH_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/src ${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} ) add_subdirectory(acceptance-tests) add_subdirectory(qml-tests) content-hub-0.0+14.04.20140415/tests/fork_and_run.h0000644000015301777760000000261312323326002022152 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef FORK_AND_RUN_H_ #define FORK_AND_RUN_H_ #include #include #include #include #include #include namespace test { bool is_child(pid_t pid) { return pid == 0; } int fork_and_run(std::function child, std::function parent) { auto pid = fork(); if (pid < 0) { throw std::runtime_error(std::string("Could not fork child: ") + std::strerror(errno)); } if (is_child(pid)) { child(); return EXIT_SUCCESS; } else { parent(); kill(pid, SIGKILL); return EXIT_SUCCESS; } return EXIT_FAILURE; } } #endif // FORK_AND_RUN_H_ content-hub-0.0+14.04.20140415/tests/acceptance-tests/0000755000015301777760000000000012323326474022573 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/tests/acceptance-tests/app_hub_communication_known_sources.cpp0000644000015301777760000001256312323326002032613 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Thomas Voß */ #include "app_manager_mock.h" #include "test_harness.h" #include "../cross_process_sync.h" #include "../fork_and_run.h" #include #include #include #include #include #include "com/ubuntu/content/detail/peer_registry.h" #include "com/ubuntu/content/detail/service.h" #include "com/ubuntu/content/serviceadaptor.h" #include #include #include #include #include #include #include namespace cua = com::ubuntu::ApplicationManager; namespace cuc = com::ubuntu::content; namespace cucd = com::ubuntu::content::detail; void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } namespace { QString service_name{"com.ubuntu.content.dbus.Service"}; struct MockedPeerRegistry : public cucd::PeerRegistry { MockedPeerRegistry() : cucd::PeerRegistry() { using namespace ::testing; ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown())); ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false)); ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false)); } MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t)); MOCK_METHOD1(enumerate_known_peers, void(const std::function&)); MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD1(remove_peer, bool(cuc::Peer)); }; } TEST(Hub, querying_known_peers_returns_correct_value) { using namespace ::testing; test::CrossProcessSync sync; QVector default_peers; default_peers << cuc::Peer("com.does.not.exist.anywhere.application1"); default_peers << cuc::Peer("com.does.not.exist.anywhere.application2"); default_peers << cuc::Peer("com.does.not.exist.anywhere.application3"); auto parent = [&sync, default_peers]() { int argc = 0; QCoreApplication app{argc, nullptr}; QDBusConnection connection = QDBusConnection::sessionBus(); auto enumerate = [default_peers](cuc::Type, const std::function& f) { Q_FOREACH(const cuc::Peer& peer, default_peers) { f(peer); } }; auto mock = new MockedPeerRegistry{}; EXPECT_CALL(*mock, enumerate_known_sources_for_type(_, _)). Times(Exactly(1)). WillRepeatedly(Invoke(enumerate)); EXPECT_CALL(*mock, install_source_for_type(_, _)). Times(Exactly(1)). WillRepeatedly(Return(true)); ASSERT_TRUE(mock->install_source_for_type(cuc::Type::Known::documents(), cuc::Peer("com.does.not.exist.anywhere.application4"))); QSharedPointer registry{mock}; auto app_manager = QSharedPointer(new MockedAppManager()); auto implementation = new cucd::Service(connection, registry, app_manager, &app); new ServiceAdaptor(implementation); ASSERT_TRUE(connection.registerService(service_name)); ASSERT_TRUE(connection.registerObject("/", implementation)); sync.signal_ready(); app.exec(); connection.unregisterObject("/"); connection.unregisterService(service_name); }; auto child = [&sync, default_peers]() { sync.wait_for_signal_ready(); int argc = 0; QCoreApplication app(argc, nullptr); auto hub = cuc::Hub::Client::instance(); test::TestHarness harness; harness.add_test_case([hub, default_peers]() { auto peers = hub->known_sources_for_type(cuc::Type::Known::documents()); ASSERT_EQ(default_peers, peers); }); EXPECT_EQ(0, QTest::qExec(std::addressof(harness))); hub->quit(); }; EXPECT_TRUE(test::fork_and_run(child, parent) != EXIT_FAILURE); } content-hub-0.0+14.04.20140415/tests/acceptance-tests/app_hub_communication_stores.cpp0000644000015301777760000001454612323326002031236 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Thomas Voß */ #include "app_manager_mock.h" #include "test_harness.h" #include "../cross_process_sync.h" #include "../fork_and_run.h" #include #include #include #include #include #include "com/ubuntu/content/detail/peer_registry.h" #include "com/ubuntu/content/detail/service.h" #include "com/ubuntu/content/serviceadaptor.h" #include #include #include #include #include #include #include namespace cua = com::ubuntu::ApplicationManager; namespace cuc = com::ubuntu::content; namespace cucd = com::ubuntu::content::detail; void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } namespace { QString service_name{"com.ubuntu.content.dbus.Service"}; struct MockedPeerRegistry : public cucd::PeerRegistry { MockedPeerRegistry() : cucd::PeerRegistry() { using namespace ::testing; ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown())); ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false)); ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false)); } MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t)); MOCK_METHOD1(enumerate_known_peers, void(const std::function&)); MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD1(remove_peer, bool(cuc::Peer)); }; } TEST(Hub, stores_are_reported_correctly_to_clients) { test::CrossProcessSync sync; auto parent = [&sync]() { int argc = 0; QCoreApplication app{argc, nullptr}; QDBusConnection connection = QDBusConnection::sessionBus(); QSharedPointer registry{new MockedPeerRegistry{}}; auto app_manager = QSharedPointer(new MockedAppManager()); auto implementation = new cucd::Service(connection, registry, app_manager, &app); new ServiceAdaptor(implementation); ASSERT_TRUE(connection.registerService(service_name)); ASSERT_TRUE(connection.registerObject("/", implementation)); sync.signal_ready(); app.exec(); connection.unregisterObject("/"); connection.unregisterService(service_name); delete implementation; }; auto child = [&sync]() { sync.wait_for_signal_ready(); test::TestHarness harness; harness.add_test_case([]() { auto hub = cuc::Hub::Client::instance(); auto system_wide_pictures_store = hub->store_for_scope_and_type(cuc::Scope::system, cuc::Type::Known::pictures()); auto system_wide_music_store = hub->store_for_scope_and_type(cuc::Scope::system, cuc::Type::Known::music()); auto system_wide_documents_store = hub->store_for_scope_and_type(cuc::Scope::system, cuc::Type::Known::documents()); auto users_pictures_store = hub->store_for_scope_and_type(cuc::Scope::user, cuc::Type::Known::pictures()); auto users_music_store = hub->store_for_scope_and_type(cuc::Scope::user, cuc::Type::Known::music()); auto users_documents_store = hub->store_for_scope_and_type(cuc::Scope::user, cuc::Type::Known::documents()); auto apps_pictures_store = hub->store_for_scope_and_type(cuc::Scope::app, cuc::Type::Known::pictures()); auto apps_music_store = hub->store_for_scope_and_type(cuc::Scope::app, cuc::Type::Known::music()); auto apps_documents_store = hub->store_for_scope_and_type(cuc::Scope::app, cuc::Type::Known::documents()); EXPECT_EQ(system_wide_pictures_store->uri(), "/content/Pictures"); EXPECT_EQ(system_wide_music_store->uri(), "/content/Music"); EXPECT_EQ(system_wide_documents_store->uri(), "/content/Documents"); auto ups = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); auto ums = QStandardPaths::writableLocation(QStandardPaths::MusicLocation); auto uds = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); EXPECT_EQ(users_pictures_store->uri(), ups); EXPECT_EQ(users_music_store->uri(), ums); EXPECT_EQ(users_documents_store->uri(), uds); auto aps = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Pictures"; auto ams = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Music"; auto ads = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Documents"; EXPECT_EQ(apps_pictures_store->uri(), aps); EXPECT_EQ(apps_music_store->uri(), ams); EXPECT_EQ(apps_documents_store->uri(), ads); hub->quit(); }); EXPECT_EQ(0, QTest::qExec(std::addressof(harness))); }; EXPECT_EQ(EXIT_SUCCESS, test::fork_and_run(child, parent)); } content-hub-0.0+14.04.20140415/tests/acceptance-tests/app_manager_mock.h0000644000015301777760000000257712323326002026225 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . */ #include "com/ubuntu/applicationmanager/application_manager.h" #include #include namespace cua = com::ubuntu::ApplicationManager; namespace { struct MockedAppManager : public cua::ApplicationManager { MockedAppManager() : cua::ApplicationManager() { using namespace ::testing; ON_CALL(*this, invoke_application(_)).WillByDefault(Return(true)); ON_CALL(*this, stop_application(_)).WillByDefault(Return(true)); ON_CALL(*this, is_application_started(_)).WillByDefault(Return(true)); } MOCK_METHOD1(invoke_application, bool(const std::string &)); MOCK_METHOD1(stop_application, bool(const std::string &)); MOCK_METHOD1(is_application_started, bool(const std::string &)); }; } content-hub-0.0+14.04.20140415/tests/acceptance-tests/good.json0000644000015301777760000000007612323326002024404 0ustar pbusernogroup00000000000000{ "source": [ "pictures", "music" ] } content-hub-0.0+14.04.20140415/tests/acceptance-tests/test_utils.cpp0000644000015301777760000000311512323326002025461 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Ken VanDine */ #include "com/ubuntu/content/utils.cpp" #include void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } QString persistent_path{"/tmp/.local/share/testing/Pictures"}; QString temp_path{"/tmp/.cache/testing/HubIncoming/1"}; TEST(Utils, is_persistent) { using namespace ::testing; EXPECT_TRUE(is_persistent(persistent_path)); EXPECT_FALSE(is_persistent(temp_path)); } TEST(Utils, purge_store_cache) { using namespace ::testing; QDir persistent_store(persistent_path); persistent_store.mkpath(persistent_store.absolutePath()); QDir temp_store(temp_path); temp_store.mkpath(temp_store.absolutePath()); EXPECT_TRUE(purge_store_cache(temp_store.absolutePath())); EXPECT_FALSE(temp_store.exists()); EXPECT_FALSE(purge_store_cache(persistent_store.absolutePath())); EXPECT_TRUE(persistent_store.exists()); } content-hub-0.0+14.04.20140415/tests/acceptance-tests/test_hook.cpp0000644000015301777760000000543612323326002025271 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Ken VanDine */ #include #include #include "com/ubuntu/content/detail/peer_registry.h" #include "com/ubuntu/content/service/hook.h" #include #include #include namespace cuc = com::ubuntu::content; void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } namespace { struct MockedRegistry : public cuc::detail::PeerRegistry { MockedRegistry() : PeerRegistry() { using namespace ::testing; ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown())); ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false)); ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false)); ON_CALL(*this, remove_peer(_)).WillByDefault(Return(false)); } MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t)); MOCK_METHOD1(enumerate_known_peers, void(const std::function&)); MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD1(remove_peer, bool(cuc::Peer)); }; } TEST(Hook, parse_json) { using namespace ::testing; auto mock = new MockedRegistry{}; EXPECT_CALL(*mock, install_source_for_type(_,_)). Times(Exactly(2)). WillRepeatedly(Return(true)); QFileInfo f("good.json"); cucd::Hook *hook = new cucd::Hook(mock); EXPECT_TRUE(hook->add_peer(f)); f.setFile("bad.json"); EXPECT_FALSE(hook->add_peer(f)); delete mock; } content-hub-0.0+14.04.20140415/tests/acceptance-tests/app_hub_communication_transfer.cpp0000644000015301777760000001630612323326002031537 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Thomas Voß */ #include "app_manager_mock.h" #include "test_harness.h" #include "../cross_process_sync.h" #include "../fork_and_run.h" #include #include #include #include #include #include #include #include "com/ubuntu/content/detail/peer_registry.h" #include "com/ubuntu/content/detail/service.h" #include "com/ubuntu/content/serviceadaptor.h" #include #include #include #include #include #include #include namespace cua = com::ubuntu::ApplicationManager; namespace cuc = com::ubuntu::content; namespace cucd = com::ubuntu::content::detail; void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } namespace { QString service_name{"com.ubuntu.content.dbus.Service"}; struct MockedPeerRegistry : public cucd::PeerRegistry { MockedPeerRegistry() : cucd::PeerRegistry() { using namespace ::testing; ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown())); ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false)); ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false)); } MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t)); MOCK_METHOD1(enumerate_known_peers, void(const std::function&)); MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD1(remove_peer, bool(cuc::Peer)); }; } TEST(Hub, transfer_creation_and_states_work) { using namespace ::testing; test::CrossProcessSync sync; auto parent = [&sync]() { int argc = 0; QCoreApplication app{argc, nullptr}; QString default_peer_id{"com.does.not.exist.anywhere.application"}; QDBusConnection connection = QDBusConnection::sessionBus(); auto mock = new ::testing::NiceMock{}; EXPECT_CALL(*mock, default_source_for_type(_)). Times(AtLeast(1)). WillRepeatedly(Return(cuc::Peer{default_peer_id})); QSharedPointer registry{mock}; auto app_manager = QSharedPointer(new MockedAppManager()); cucd::Service implementation(connection, registry, app_manager, &app); new ServiceAdaptor(std::addressof(implementation)); ASSERT_TRUE(connection.registerService(service_name)); ASSERT_TRUE(connection.registerObject("/", std::addressof(implementation))); sync.signal_ready(); app.exec(); connection.unregisterObject("/"); connection.unregisterService(service_name); }; auto child = [&sync]() { int argc = 0; QCoreApplication app(argc, nullptr); app.setApplicationName("com.some.test.app"); sync.wait_for_signal_ready(); test::TestHarness harness; harness.add_test_case([]() { QVector source_items; source_items << cuc::Item(QUrl::fromLocalFile(QFileInfo("file1").absoluteFilePath())); source_items << cuc::Item(QUrl::fromLocalFile(QFileInfo("file2").absoluteFilePath())); source_items << cuc::Item(QUrl::fromLocalFile(QFileInfo("file3").absoluteFilePath())); QVector expected_items; expected_items << cuc::Item(QUrl("file:///tmp/Incoming/file1")); expected_items << cuc::Item(QUrl("file:///tmp/Incoming/file2")); expected_items << cuc::Item(QUrl("file:///tmp/Incoming/file3")); /** [Importing pictures] */ auto hub = cuc::Hub::Client::instance(); auto transfer = hub->create_import_from_peer( hub->default_source_for_type(cuc::Type::Known::pictures())); ASSERT_TRUE(transfer != nullptr); EXPECT_EQ(cuc::Transfer::created, transfer->state()); EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::multiple)); ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType()); transfer->setStore(new cuc::Store{"/tmp/Incoming"}); EXPECT_TRUE(transfer->start()); EXPECT_EQ(cuc::Transfer::initiated, transfer->state()); EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::single)); ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType()); EXPECT_TRUE(transfer->charge(source_items)); EXPECT_EQ(cuc::Transfer::charged, transfer->state()); EXPECT_EQ(expected_items, transfer->collect()); /** [Importing pictures] */ /* Test that only a single transfer exists for the same peer */ auto single_transfer = hub->create_import_from_peer( hub->default_source_for_type(cuc::Type::Known::pictures())); ASSERT_TRUE(single_transfer != nullptr); EXPECT_EQ(cuc::Transfer::created, single_transfer->state()); EXPECT_TRUE(single_transfer->start()); EXPECT_EQ(cuc::Transfer::initiated, single_transfer->state()); auto second_transfer = hub->create_import_from_peer( hub->default_source_for_type(cuc::Type::Known::pictures())); ASSERT_TRUE(second_transfer != nullptr); EXPECT_EQ(cuc::Transfer::created, second_transfer->state()); /* Now that a second transfer was created, the previous * transfer should have been aborted */ EXPECT_EQ(cuc::Transfer::aborted, single_transfer->state()); /* end single transfer test */ hub->quit(); }); EXPECT_EQ(0, QTest::qExec(std::addressof(harness))); }; EXPECT_EQ(EXIT_SUCCESS, test::fork_and_run(child, parent)); } content-hub-0.0+14.04.20140415/tests/acceptance-tests/CMakeLists.txt0000644000015301777760000000626312323326002025325 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss qt5_wrap_cpp(MOCS test_harness.h) add_executable( app_hub_communication_default_source app_hub_communication_default_source.cpp ${MOCS} ) add_executable( app_hub_communication_known_sources app_hub_communication_known_sources.cpp ${MOCS} ) add_executable( app_hub_communication_stores app_hub_communication_stores.cpp ${MOCS} ) add_executable( app_hub_communication_transfer app_hub_communication_transfer.cpp ${MOCS} ) add_executable( app_hub_communication_handler app_hub_communication_handler.cpp ${MOCS} transfer_files ) add_executable( test_utils test_utils.cpp ) add_executable( test_hook test_hook.cpp ${MOCS} ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/hook.cpp ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/registry.cpp good.json bad.json ) qt5_use_modules(app_hub_communication_default_source Core Gui DBus Test) qt5_use_modules(app_hub_communication_known_sources Core Gui DBus Test) qt5_use_modules(app_hub_communication_stores Core Gui DBus Test) qt5_use_modules(app_hub_communication_transfer Core Gui DBus Test) qt5_use_modules(app_hub_communication_handler Core Gui DBus Test) qt5_use_modules(test_utils Core Test) qt5_use_modules(test_hook Core Gui DBus Test) target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main) target_link_libraries(app_hub_communication_default_source content-hub gmock gtest gtest_main) target_link_libraries(app_hub_communication_known_sources content-hub gmock gtest gtest_main) target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main) target_link_libraries(app_hub_communication_transfer content-hub gmock gtest gtest_main) target_link_libraries(app_hub_communication_handler content-hub gmock gtest gtest_main) target_link_libraries(test_utils content-hub gmock gtest gtest_main) target_link_libraries(test_hook content-hub gmock gtest gtest_main ${GSETTINGS_LDFLAGS}) add_test(app_hub_communication_default_source app_hub_communication_default_source) add_test(app_hub_communication_known_sources app_hub_communication_known_sources) add_test(app_hub_communication_stores app_hub_communication_stores) add_test(app_hub_communication_transfer app_hub_communication_transfer) add_test(app_hub_communication_handler app_hub_communication_handler) add_test(test_utils test_utils) add_test(test_hook test_hook) set_target_properties( test_hook PROPERTIES AUTOMOC TRUE ) file(COPY good.json bad.json DESTINATION .) add_custom_command( OUTPUT transfer_files COMMAND cmake -E touch file1 file2 file3 ) content-hub-0.0+14.04.20140415/tests/acceptance-tests/app_hub_communication_handler.cpp0000644000015301777760000001306312323326002031325 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Ken VanDine */ #include "app_manager_mock.h" #include "test_harness.h" #include "../cross_process_sync.h" #include "../fork_and_run.h" #include #include #include #include #include #include #include #include "com/ubuntu/content/utils.cpp" #include "com/ubuntu/content/detail/peer_registry.h" #include "com/ubuntu/content/detail/service.h" #include "com/ubuntu/content/serviceadaptor.h" #include #include #include #include #include #include #include namespace cua = com::ubuntu::ApplicationManager; namespace cuc = com::ubuntu::content; namespace cucd = com::ubuntu::content::detail; void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } namespace { QString service_name{"com.ubuntu.content.dbus.Service"}; struct MockedPeerRegistry : public cucd::PeerRegistry { MockedPeerRegistry() : cucd::PeerRegistry() { using namespace ::testing; } MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t)); MOCK_METHOD1(enumerate_known_peers, void(const std::function&)); MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD1(remove_peer, bool(cuc::Peer)); }; struct MockedHandler : public cuc::ImportExportHandler { MockedHandler() : cuc::ImportExportHandler() { using namespace ::testing; ON_CALL(*this, handle_import(_)).WillByDefault(Return()); ON_CALL(*this, handle_export(_)).WillByDefault(Return()); ON_CALL(*this, handle_share(_)).WillByDefault(Return()); } MOCK_METHOD1(handle_import, void(cuc::Transfer*)); MOCK_METHOD1(handle_export, void(cuc::Transfer*)); MOCK_METHOD1(handle_share, void(cuc::Transfer*)); }; } TEST(Handler, handler_on_bus) { using namespace ::testing; QString default_peer_id{"com.does.not.exist.anywhere.application"}; QString default_dest_peer_id{"com.also.does.not.exist.anywhere.application"}; test::CrossProcessSync sync; auto parent = [&sync, default_peer_id]() { int argc = 0; QCoreApplication app{argc, nullptr}; QDBusConnection connection = QDBusConnection::sessionBus(); QSharedPointer registry{new MockedPeerRegistry{}}; auto app_manager = QSharedPointer(new MockedAppManager()); auto implementation = new cucd::Service(connection, registry, app_manager, &app); new ServiceAdaptor(implementation); ASSERT_TRUE(connection.registerService(service_name)); ASSERT_TRUE(connection.registerObject("/", implementation)); sync.signal_ready(); app.exec(); connection.unregisterObject("/"); connection.unregisterService(service_name); delete implementation; }; auto child = [&sync, default_peer_id, default_dest_peer_id]() { sync.wait_for_signal_ready(); int argc = 0; QCoreApplication app(argc, nullptr); test::TestHarness harness; harness.add_test_case([default_peer_id, default_dest_peer_id]() { /* register handler on the service */ auto mock_handler = new MockedHandler{}; EXPECT_CALL(*mock_handler, handle_export(_)).Times(Exactly(1)); qputenv("APP_ID", default_peer_id.toLatin1()); auto hub = cuc::Hub::Client::instance(); hub->register_import_export_handler(mock_handler); hub->quit(); qputenv("APP_ID", default_dest_peer_id.toLatin1()); hub = cuc::Hub::Client::instance(); auto transfer = hub->create_import_from_peer(cuc::Peer(default_peer_id)); ASSERT_TRUE(transfer != nullptr); EXPECT_TRUE(transfer->start()); EXPECT_EQ(cuc::Transfer::in_progress, transfer->state()); EXPECT_EQ(cuc::Transfer::charged, transfer->state()); hub->quit(); delete mock_handler; }); EXPECT_EQ(0, QTest::qExec(std::addressof(harness))); }; EXPECT_TRUE(test::fork_and_run(child, parent) != EXIT_FAILURE); } content-hub-0.0+14.04.20140415/tests/acceptance-tests/test_harness.h0000644000015301777760000000255312323326002025436 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Thomas Voß */ #ifndef TEST_HARNESS_H_ #define TEST_HARNESS_H_ #include #include #include #include namespace test { class TestHarness : public QObject { Q_OBJECT public: TestHarness(QObject* parent = nullptr) : QObject(parent) { } virtual ~TestHarness() { } void add_test_case(const std::function& test_case) { known_test_cases.push_back(test_case); } private: std::list> known_test_cases; private Q_SLOTS: void run() { for(auto test_case : known_test_cases) { test_case(); } } }; } #endif // TEST_HARNESS_H_ content-hub-0.0+14.04.20140415/tests/acceptance-tests/app_hub_communication_default_source.cpp0000644000015301777760000001117312323326002032714 0ustar pbusernogroup00000000000000/* * Copyright © 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 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 . * * Authored by: Thomas Voß */ #include "app_manager_mock.h" #include "test_harness.h" #include "../cross_process_sync.h" #include "../fork_and_run.h" #include #include #include #include #include #include "com/ubuntu/content/serviceadaptor.h" #include "com/ubuntu/content/detail/peer_registry.h" #include "com/ubuntu/content/detail/service.h" #include #include #include #include #include #include #include namespace cua = com::ubuntu::ApplicationManager; namespace cuc = com::ubuntu::content; namespace cucd = com::ubuntu::content::detail; void PrintTo(const QString& s, ::std::ostream* os) { *os << std::string(qPrintable(s)); } namespace { QString service_name{"com.ubuntu.content.dbus.Service"}; struct MockedPeerRegistry : public cucd::PeerRegistry { MockedPeerRegistry() : cucd::PeerRegistry() { using namespace ::testing; ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown())); ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false)); ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false)); } MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t)); MOCK_METHOD1(enumerate_known_peers, void(const std::function&)); MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function&)); MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer)); MOCK_METHOD1(remove_peer, bool(cuc::Peer)); }; } TEST(Hub, querying_default_peer_returns_correct_value) { using namespace ::testing; test::CrossProcessSync sync; QString default_peer_id{"com.does.not.exist.anywhere.application"}; auto parent = [&sync, default_peer_id]() { int argc = 0; QCoreApplication app{argc, nullptr}; QDBusConnection connection = QDBusConnection::sessionBus(); auto mock = new MockedPeerRegistry{}; EXPECT_CALL(*mock, default_source_for_type(_)). Times(Exactly(1)). WillRepeatedly(Return(cuc::Peer{default_peer_id})); QSharedPointer registry{mock}; auto app_manager = QSharedPointer(new MockedAppManager()); auto implementation = new cucd::Service(connection, registry, app_manager, &app); new ServiceAdaptor(implementation); ASSERT_TRUE(connection.registerService(service_name)); ASSERT_TRUE(connection.registerObject("/", implementation)); sync.signal_ready(); app.exec(); connection.unregisterObject("/"); connection.unregisterService(service_name); }; auto child = [&sync, default_peer_id]() { sync.wait_for_signal_ready(); int argc = 0; QCoreApplication app(argc, nullptr); auto hub = cuc::Hub::Client::instance(); test::TestHarness harness; harness.add_test_case([hub, default_peer_id]() { EXPECT_EQ(default_peer_id, hub->default_source_for_type(cuc::Type::Known::documents()).id()); }); EXPECT_EQ(0, QTest::qExec(std::addressof(harness))); hub->quit(); }; EXPECT_TRUE(test::fork_and_run(child, parent) != EXIT_FAILURE); } content-hub-0.0+14.04.20140415/tests/acceptance-tests/bad.json0000644000015301777760000000007712323326002024203 0ustar pbusernogroup00000000000000{ "source": [ "pictures", "music", ] } content-hub-0.0+14.04.20140415/tests/qml-tests/0000755000015301777760000000000012323326474021276 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/tests/qml-tests/tst_QmlTests.cpp0000644000015301777760000000130412323326002024431 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #include QUICK_TEST_MAIN(QmlTests) content-hub-0.0+14.04.20140415/tests/qml-tests/CMakeLists.txt0000644000015301777760000000323312323326002024022 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . set(TEST tst_QmlTests) add_executable(${TEST} tst_QmlTests.cpp) qt5_use_modules(${TEST} Core Qml Quick Test QuickTest) add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST}) set_tests_properties(${TEST} PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal;QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/import;APP_ID=com.some.app.for.testing") # copy qml files under test to build dir set(out_qml_files) if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) # copy qml test files to build dir file(GLOB qmlTestFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml) foreach(qmlTestFile ${qmlTestFiles}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${qmlTestFile} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${qmlTestFile} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${qmlTestFile} ${CMAKE_CURRENT_BINARY_DIR}/${qmlTestFile}) endforeach(qmlTestFile) add_custom_target(copy_qml_test_files_to_build_dir DEPENDS ${qmlTestFiles}) add_dependencies(${TEST} copy_qml_test_files_to_build_dir) endif() content-hub-0.0+14.04.20140415/tests/qml-tests/tst_ContentHub.qml0000644000015301777760000000446112323326002024744 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ import QtQuick 2.0 import QtTest 1.0 import Ubuntu.Content 0.1 TestCase { name: "ContentHub" function test_default_import() { var transfer = sourcePeer.request(); verify(transfer !== null, "No transer Object returned") } function test_select_for_import() { var transfer = sourcePeer.request(); verify(transfer !== null, "No transer Object returned") } function test_export_request() { var filePath = "file:///foo/bar.png"; var transfer = destPeer.request(); transfer.items = [ resultComponent.createObject(test, {"url": filePath}) ]; transfer.state = ContentTransfer.Charged; // This shouldn't be necessary, but without it we compare the results to fast ContentHub.exportRequested(transfer); compare(test.exportTransfer, transfer, "Transfer object not correcty set"); compare(test.exportTransfer.items[0].url, filePath, "Transfer contents incorrect"); } Component { id: resultComponent ContentItem {} } ContentPeer { id: sourcePeer handler: ContentHandler.Source contentType: ContentType.Pictures } ContentPeer { id: destPeer handler: ContentHandler.Destination contentType: ContentType.Pictures appId: "com.some.dest" } Item { id: test property variant exportTransfer property int numImports: 0 Connections { target: ContentHub onExportRequested: { test.exportTransfer = transfer; } onFinishedImportsChanged: { test.numImports++; } } } } content-hub-0.0+14.04.20140415/doc/0000755000015301777760000000000012323326474016750 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/doc/extra.css0000644000015301777760000000127112323326002020571 0ustar pbusernogroup00000000000000body, table, div, p, dl { font: 400 14px/19px Ubuntu,Arial,sans-serif; } #projectname { font: 300% Ubuntu,Arial,sans-serif; margin: 0px; padding: 2px 0px; } #projectbrief { font: 120% Ubuntu,Arial,sans-serif; margin: 0px; padding: 0px; } #projectnumber { font: 50% Ubuntu,Arial,sans-serif; margin: 0px; padding: 0px; } div.toc li { background: url("bdwn.png") no-repeat scroll 0 5px transparent; font: 10px/1.2 Ubuntu,Arial,sans-serif; margin-top: 5px; padding-left: 10px; padding-top: 2px; } div.toc h3 { font: bold 12px/1.2 Ubuntu,Arial,FreeSans,sans-serif; color: #E24106; border-bottom: 0 none; margin: 0; } content-hub-0.0+14.04.20140415/doc/Mainpage.md0000644000015301777760000000575512323326002021012 0ustar pbusernogroup00000000000000Content Management & Exchange {#mainpage} ============================= Unity and the overall Ubuntu experience put heavy emphasis on the notion of content, with Unity’s dash offering streamlined access to arbitrary content, both local to the device or online. More to this, Unity’s dash is the primary way of surfacing content on mobile form factors without the need to access individual applications and their respective content silos. The content-hub deals with application-specific content management and implements an architecture that allows an app to define its own content silo, exchange content with other applications/the system, and a way to provide the user with content picking functionality. To ease conversations, we start over with a set of definitions: - Content item: A content item is an entity that consists of meta-data and data. E.g., an image is a content item, where the actual pixels are the data, and information like size, image format, bit depth, location etc. is considered meta data. \sa com::ubuntu::content::Item. - Content types: A set of well-known content types. E.g., images or music files. \sa com::ubuntu::content::Type. - Content set: A set of unique content items. Can be considered a content item itself, e.g., in the case of playlists. - Content owner: The unique owner of a content item. A content item has to be owned by exactly one app. \sa com::ubuntu::content::Peer - Content store: A container (think of it as a top-level folder in the filesystem) that contains content items of a certain type. Different stores exist for different scopes, where scope refers to either system-wide, user-wide or app-specific storage locations. \sa com::ubuntu::content::Store, com::ubuntu::content::Scope - Content transfer: Transferring content item/s to and from a source or destination. A transfer is uniquely defined by: * The content source * The content destination * The transfer direction, either import or export * The set of items that should be exchanged \sa com::ubuntu::content::Transfer, com::ubuntu::content::Hub::create_import_for_type_from_peer - Content picking: Operation that allows a user to select content for subsequent import from a content source (e.g., an application). The content source is responsible for providing a UI to the user. Architectural Overview ---------------------- The architecture enforces complete application isolation, both in terms of content separation, sandboxing/confinement and in terms of the application lifecycle. As we cannot assume that two apps that want to exchange content are running at the same time, a system-level component needs to mediate and control the content exchange operation, making sure that neither app instance assumes the existence of the other one. We refer to this component as the content hub. \sa com::ubuntu::content::Hub Example usage - Importing Pictures ---------------------------------- \snippet acceptance-tests/app_hub_communication_transfer.cpp Importing picturescontent-hub-0.0+14.04.20140415/doc/Doxyfile.in0000644000015301777760000023450112323326002021053 0ustar pbusernogroup00000000000000# Doxyfile 1.8.3.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = "Content Hub" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @CONTENT_HUB_VERSION_MAJOR@.@CONTENT_HUB_VERSION_MINOR@.@CONTENT_HUB_VERSION_PATCH@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A session-wide content-exchange service" # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. Note that you specify absolute paths here, but also # relative paths, which will be relative from the directory where doxygen is # started. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, # and language is one of the parsers supported by doxygen: IDL, Java, # Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, # C++. For instance to make doxygen treat .inc files as Fortran files (default # is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note # that for custom extensions you also need to set FILE_PATTERNS otherwise the # files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented classes, # or namespaces to their corresponding documentation. Such a link can be # prevented in individual cases by by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES (the # default) will make doxygen replace the get and set methods by a property in # the documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if section-label ... \endif # and \cond section-label ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. Do not use # file names with spaces, bibtex cannot handle them. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @CMAKE_CURRENT_SOURCE_DIR@ @CMAKE_CURRENT_SOURCE_DIR@/../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/../tests # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = # If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page (index.html). # This can be useful if you have a project on for instance GitHub and want reuse # the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/Mainpage.md #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If left blank doxygen will # generate a default style sheet. Note that it is recommended to use # HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this # tag will in the future become obsolete. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional # user-defined cascading style sheet that is included after the standard # style sheets created by doxygen. Using this option one can overrule # certain style aspects. This is preferred over using HTML_STYLESHEET # since it does not replace the standard style sheet and is therefor more # robust against future updates. Doxygen will copy the style sheet file to # the output directory. HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/extra.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = YES # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of # entries shown in the various tree structured indices initially; the user # can expand and collapse entries dynamically later on. Doxygen will expand # the tree to such a level that at most the specified number of entries are # visible (unless a fully collapsed tree already exceeds this amount). # So setting the number of entries 1 will produce a full collapsed tree by # default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely # identify the documentation publisher. This should be a reverse domain-name # style string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = YES # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 1 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and # SVG. The default value is HTML-CSS, which is slower, but has the best # compatibility. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. # There are two flavours of web server based search depending on the # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for # searching and an index file used by the script. When EXTERNAL_SEARCH is # enabled the indexing and searching needs to be provided by external tools. # See the manual for details. SERVER_BASED_SEARCH = NO # When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file # which needs to be processed by an external indexer. Doxygen will invoke an # external search engine pointed to by the SEARCHENGINE_URL option to obtain # the search results. Doxygen ships with an example indexer (doxyindexer) and # search engine (doxysearch.cgi) which are based on the open source search engine # library Xapian. See the manual for configuration details. EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will returned the search results when EXTERNAL_SEARCH is enabled. # Doxygen ships with an example search engine (doxysearch) which is based on # the open source search engine library Xapian. See the manual for configuration # details. SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the # SEARCHDATA_FILE tag the name of this file can be specified. SEARCHDATA_FILE = searchdata.xml # When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple # projects and redirect the results back to the right project. EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are # all added to the same external search index. Each project needs to have a # unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id # of to a relative location where the documentation can be found. # The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = NO # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = YES # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = YES # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = YES # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = YES # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES content-hub-0.0+14.04.20140415/doc/CMakeLists.txt0000644000015301777760000000232212323326002021472 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss add_custom_target(doc ALL) find_package(Doxygen) if(DOXYGEN_FOUND) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(cppdoc ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}/cpp) add_dependencies(doc cppdoc) endif(DOXYGEN_FOUND) add_subdirectory(qml) content-hub-0.0+14.04.20140415/doc/qml/0000755000015301777760000000000012323326474017541 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/doc/qml/pages/0000755000015301777760000000000012323326474020640 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/doc/qml/pages/mainpage.qdoc0000644000015301777760000001103312323326002023252 0ustar pbusernogroup00000000000000/*! \page index.html overview \title Ubuntu Content API \contentspage {Ubuntu Content API} {Contents} \part Content Management & Exchange \chapter Introduction Unity and the overall Ubuntu experience put heavy emphasis on the notion of content, with Unity’s dash offering streamlined access to arbitrary content, both local to the device or online. More to this, Unity’s dash is the primary way of surfacing content on mobile form factors without the need to access individual applications and their respective content silos. The content-hub deals with application-specific content management and implements an architecture that allows an app to define its own content silo, exchange content with other applications/the system, and a way to provide the user with content picking functionality. \section1 Definitions To ease conversations, we start over with a set of definitions: \list \li \b {Content item}: A content item is an entity that consists of meta-data and data. E.g., an image is a content item, where the actual pixels are the data, and information like size, image format, bit depth, location etc. is considered meta data. See also \l ContentItem. \li \b {Content types}: A set of well-known content types. E.g., images or music files. See also \l {ContentType} \li \b {Content set}: A set of unique content items. Can be considered a content item itself, e.g., in the case of playlists. \li \b {Content owner}: The unique owner of a content item. A content item has to be owned by exactly one app. See also \l {ContentPeer} \li \b {Content store}: A container (think of it as a top-level folder in the filesystem) that contains content items of a certain type. Different stores exist for different scopes, where scope refers to either system-wide, user-wide or app-specific storage locations. See also \l {ContentStore} \li \b {Content transfer}: Transferring content item/s to and from a source or destination. A transfer is uniquely defined by a source, destination, direction (import or export), and a set of items that should be exchanged. See also \l {ContentTransfer} \li \b {Content picking}: Operation that allows a user to select content for subsequent import from a content source (e.g., an application). The content source is responsible for providing a UI to the user. \endlist \section1 Architectural Overview The architecture enforces complete application isolation, both in terms of content separation, sandboxing/confinement and in terms of the application lifecycle. As we cannot assume that two apps that want to exchange content are running at the same time, a system-level component needs to mediate and control the content exchange operation, making sure that neither app instance assumes the existence of the other one. We refer to this component as the content hub. \sa {ContentHub} \section1 Example usage - Importing Pictures \qml import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Content 0.1 Rectangle { id: root property list importItems property var activeTransfer ContentPeer { id: picSourceSingle contentType: ContentType.Pictures handler: ContentHandler.Source selectionType: ContentTransfer.Single } ContentPeer { id: picSourceMulti contentType: ContentType.Pictures handler: ContentHandler.Source selectionType: ContentTransfer.Multiple } Row { Button { text: "Import single item" onClicked: { activeTransfer = picSourceSingle.request() } } Button { text: "Import multiple items" onClicked: { activeTransfer = picSourceMulti.request() } } } ContentTransferHint { id: transferHint anchors.fill: parent activeTransfer: root.activeTransfer } Connections { target: root.activeTransfer onStateChanged: { if (root.activeTransfer.state === ContentTransfer.Charged) importItems = root.activeTransfer.items; } } } \endqml \part General Topics \list \li \l {ContentHub} \li \l {ContentPeer} \li \l {ContentPeerModel} \li \l {ContentPeerPicker} \li \l {ContentStore} \li \l {ContentTransfer} \li \l {ContentTransferHint} \li \l {ContentType} \endlist \part Reporting Bugs If you find any problems with the or this documentation, please file a bug in Ubuntu Content API \l {https://bugs.launchpad.net/content-hub} {Launchpad page} \part Components Available through: \code import Ubuntu.Content 0.1 \endcode */ content-hub-0.0+14.04.20140415/doc/qml/pages/moduledef.qdoc0000644000015301777760000000004612323326002023437 0ustar pbusernogroup00000000000000/*! \qmlmodule Ubuntu.Content 0.1 */ content-hub-0.0+14.04.20140415/doc/qml/CMakeLists.txt0000644000015301777760000000141012323326002022260 0ustar pbusernogroup00000000000000# add a target to generate API documentation with qdoc FIND_PROGRAM(QDOC_EXECUTABLE qdoc) if(QDOC_EXECUTABLE) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ubuntu-content-hub.qdocconf.in ${CMAKE_CURRENT_BINARY_DIR}/ubuntu-content-hub.qdocconf @ONLY) add_custom_target(qmldoc ${QDOC_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/ubuntu-content-hub.qdocconf WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating QML API documentation with qdoc" VERBATIM ) # copy stylesheet files into build directory for shadow builds file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/css" DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/qml/html ) add_dependencies(doc qmldoc) endif(QDOC_EXECUTABLE) content-hub-0.0+14.04.20140415/doc/qml/ubuntu-content-hub.qdocconf.in0000644000015301777760000000303212323326035025421 0ustar pbusernogroup00000000000000project = Ubuntu Content QML API description = Ubuntu Content API # QDoc 5.2 will only process these if they're relative paths sourcedirs = ../../../doc/qml/pages ../../../import exampledirs = ../../../examples/ sources.fileextensions = "*.qdoc *.qml *.cpp" headers.fileextensions = "*.h" examples.fileextensions = "*.js *.qml" examples.imageextensions = "*.png *.jpeg *.jpg" # But... QDoc 5.2 will also only process this if it's an absolute path excludefiles = @CMAKE_SOURCE_DIR@/import/Ubuntu/Content/ResponsiveGridView.qml outputdir = html outputformat = HTML outputprefixes = QML outputprefixes.QML = qml- HTML.templatedir = ../../../doc/ HTML.nobreadcrumbs = "true" HTML.stylesheets = \ css/reset.css \ css/qtquick.css \ css/base.css \ css/scratch.css HTML.headerstyles = \ "\n" \ "\n" \ "\n" \ "\n" HTML.postheader = \ "
\n" \ "
\n" HTML.footer = \ "
\n" \ "
\n" \ "
\n" \ "
\n" \ " \n" \ "

© 2013 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.

\n" \ "
\n" \ "
\n" content-hub-0.0+14.04.20140415/doc/qml/css/0000755000015301777760000000000012323326474020331 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/doc/qml/css/qtquick.css0000644000015301777760000003175112323326002022516 0ustar pbusernogroup00000000000000@media screen { /* basic elements */ html { color: #000000; background: #FFFFFF; } table { border-collapse: collapse; border-spacing: 0; } fieldset, img { border: 0; max-width:100%; } address, caption, cite, code, dfn, em, strong, th, var, optgroup { font-style: inherit; font-weight: inherit; } del, ins { text-decoration: none; } ol li { list-style: decimal; } ul li { list-style: none; } caption, th { text-align: left; } h1.title { font-weight: bold; font-size: 150%; } h0 { font-weight: bold; font-size: 130%; } h1, h2, h3, h4, h5, h6 { font-size: 100%; } q:before, q:after { content: ''; } abbr, acronym { border: 0; font-variant: normal; } sup, sub { vertical-align: baseline; } tt, .qmlreadonly span, .qmldefault span { word-spacing:0.5em; } legend { color: #000000; } strong { font-weight: bold; } em { font-style: italic; } body { margin: 0 1.5em 0 1.5em; font-family: ubuntu; line-height: normal } a { color: #00732F; text-decoration: none; } hr { background-color: #E6E6E6; border: 1px solid #E6E6E6; height: 1px; width: 100%; text-align: left; margin: 1.5em 0 1.5em 0; } pre { border: 1px solid #DDDDDD; -moz-border-radius: 0.7em 0.7em 0.7em 0.7em; -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em; border-radius: 0.7em 0.7em 0.7em 0.7em; padding: 1em 1em 1em 1em; overflow-x: auto; } table, pre { -moz-border-radius: 0.7em 0.7em 0.7em 0.7em; -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em; border-radius: 0.7em 0.7em 0.7em 0.7em; background-color: #F6F6F6; border: 1px solid #E6E6E6; border-collapse: separate; margin-bottom: 2.5em; } pre { font-size: 90%; display: block; overflow:hidden; } thead { margin-top: 0.5em; font-weight: bold } th { padding: 0.5em 1.5em 0.5em 1em; background-color: #E1E1E1; border-left: 1px solid #E6E6E6; } td { padding: 0.25em 1.5em 0.25em 1em; } td.rightAlign { padding: 0.25em 0.5em 0.25em 1em; } table tr.odd { border-left: 1px solid #E6E6E6; background-color: #F6F6F6; color: black; } table tr.even { border-left: 1px solid #E6E6E6; background-color: #ffffff; color: #202020; } div.float-left { float: left; margin-right: 2em } div.float-right { float: right; margin-left: 2em } span.comment { color: #008B00; } span.string, span.char { color: #000084; } span.number { color: #a46200; } span.operator { color: #202020; } span.keyword { color: #840000; } span.name { color: black } span.type { font-weight: bold } span.type a:visited { color: #0F5300; } span.preprocessor { color: #404040 } /* end basic elements */ /* font style elements */ .heading { font-weight: bold; font-size: 125%; } .subtitle { font-size: 110% } .small-subtitle { font-size: 100% } .red { color:red; } /* end font style elements */ /* global settings*/ .header, .footer { display: block; clear: both; overflow: hidden; } /* end global settings*/ /* header elements */ .header .qtref { color: #00732F; font-weight: bold; font-size: 130%; } .header .content { margin-left: 5px; margin-top: 5px; margin-bottom: 0.5em; } .header .breadcrumb { font-size: 90%; padding: 0.5em 0 0.5em 1em; margin: 0; background-color: #fafafa; height: 1.35em; border-bottom: 1px solid #d1d1d1; } .header .breadcrumb ul { margin: 0; padding: 0; } .header .content { word-wrap: break-word; } .header .breadcrumb ul li { float: left; background: url(../images/breadcrumb.png) no-repeat 0 3px; padding-left: 1.5em; margin-left: 1.5em; } .header .breadcrumb ul li.last { font-weight: normal; } .header .breadcrumb ul li a { color: #00732F; } .header .breadcrumb ul li.first { background-image: none; padding-left: 0; margin-left: 0; } .header .content ol li { background: none; margin-bottom: 1.0em; margin-left: 1.2em; padding-left: 0 } .header .content li { background: url(../images/bullet_sq.png) no-repeat 0 5px; margin-bottom: 1em; padding-left: 1.2em; } /* end header elements */ /* content elements */ .content h1 { font-weight: bold; font-size: 130% } .content h2 { font-weight: bold; font-size: 120%; width: 100%; } .content h3 { font-weight: bold; font-size: 110%; width: 100%; } .content table p { margin: 0 } .content ul { padding-left: 2.5em; } .content li { padding-top: 0.25em; padding-bottom: 0.25em; } .content ul img { vertical-align: middle; } .content a:visited { color: #4c0033; text-decoration: none; } .content a:visited:hover { color: #4c0033; text-decoration: underline; } a:hover { color: #4c0033; text-decoration: underline; } descr p a { text-decoration: underline; } .descr p a:visited { text-decoration: underline; } .alphaChar{ width:95%; background-color:#F6F6F6; border:1px solid #E6E6E6; -moz-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; font-size:12pt; padding-left:10px; margin-top:10px; margin-bottom:10px; } .flowList{ /*vertical-align:top;*/ /*margin:20px auto;*/ column-count:3; -webkit-column-count:3; -moz-column-count:3; /* column-width:100%; -webkit-column-width:200px; -col-column-width:200px; */ column-gap:41px; -webkit-column-gap:41px; -moz-column-gap:41px; column-rule: 1px dashed #ccc; -webkit-column-rule: 1px dashed #ccc; -moz-column-rule: 1px dashed #ccc; } .flowList dl{ } .flowList dd{ /*display:inline-block;*/ margin-left:10px; min-width:250px; line-height: 1.5; min-width:100%; min-height:15px; } .flowList dd a{ } .mainContent { padding-left:5px; } .content .flowList p{ padding:0px; } .content .alignedsummary { margin: 15px; } .qmltype { text-align: center; font-size: 120%; } .qmlreadonly { padding-left: 5px; float: right; color: #254117; } .qmldefault { padding-left: 5px; float: right; color: red; } .qmldoc { } .generic .alphaChar{ margin-top:5px; } .generic .odd .alphaChar{ background-color: #F6F6F6; } .generic .even .alphaChar{ background-color: #FFFFFF; } .memItemRight{ padding: 0.25em 1.5em 0.25em 0; } .highlightedCode { margin: 1.0em; } .annotated td { padding: 0.25em 0.5em 0.25em 0.5em; } .toc { font-size: 80% } .header .content .toc ul { padding-left: 0px; } .content .toc h3 { border-bottom: 0px; margin-top: 0px; } .content .toc h3 a:hover { color: #00732F; text-decoration: none; } .content .toc .level2 { margin-left: 1.5em; } .content .toc .level3 { margin-left: 3.0em; } .content ul li { background: url(../images/bullet_sq.png) no-repeat 0 0.7em; padding-left: 1em } .content .toc li { background: url(../images/bullet_dn.png) no-repeat 0 5px; padding-left: 1em } .relpage { -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; border: 1px solid #DDDDDD; padding: 25px 25px; clear: both; } .relpage ul { float: none; padding: 1.5em; } h3.fn, span.fn { -moz-border-radius:7px 7px 7px 7px; -webkit-border-radius:7px 7px 7px 7px; border-radius:7px 7px 7px 7px; background-color: #F6F6F6; border-width: 1px; border-style: solid; border-color: #E6E6E6; font-weight: bold; word-spacing:3px; padding:3px 5px; } .functionIndex { font-size:12pt; word-spacing:10px; margin-bottom:10px; background-color: #F6F6F6; border-width: 1px; border-style: solid; border-color: #E6E6E6; -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; width:100%; } .centerAlign { text-align:center; } .rightAlign { text-align:right; } .leftAlign { text-align:left; } .topAlign{ vertical-align:top } .functionIndex a{ display:inline-block; } /* end content elements */ /* footer elements */ .footer { color: #393735; font-size: 0.75em; text-align: center; padding-top: 1.5em; padding-bottom: 1em; background-color: #E6E7E8; margin: 0; } .footer p { margin: 0.25em } .small { font-size: 0.5em; } /* end footer elements */ .item { float: left; position: relative; width: 100%; overflow: hidden; } .item .primary { margin-right: 220px; position: relative; } .item hr { margin-left: -220px; } .item .secondary { float: right; width: 200px; position: relative; } .item .cols { clear: both; display: block; } .item .cols .col { float: left; margin-left: 1.5%; } .item .cols .col.first { margin-left: 0; } .item .cols.two .col { width: 45%; } .item .box { margin: 0 0 10px 0; } .item .box h3 { margin: 0 0 10px 0; } .cols.unclear { clear:none; } } /* end of screen media */ /* start of print media */ @media print { input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft, #feedbackBox, #blurpage, .toc, .breadcrumb, .toolbar, .floatingResult { display: none; background: none; } .content { background: none; display: block; width: 100%; margin: 0; float: none; } } /* end of print media */ /* modify the TOC layouts */ div.toc ul { padding-left: 20px; } div.toc li { padding-left: 4px; } /* Remove the border around images*/ a img { border:none; } /*Add styling to the front pages*/ .threecolumn_area { padding-top: 20px; padding-bottom: 20px; } .threecolumn_piece { display: inline-block; margin-left: 78px; margin-top: 8px; padding: 0; vertical-align: top; width: 25.5%; } div.threecolumn_piece ul { list-style-type: none; padding-left: 0px; margin-top: 2px; } div.threecolumn_piece p { margin-bottom: 7px; color: #5C626E; text-decoration: none; font-weight: bold; } div.threecolumn_piece li { padding-left: 0px; margin-bottom: 5px; } div.threecolumn_piece a { font-weight: normal; } /* Add style to guide page*/ .fourcolumn_area { padding-top: 20px; padding-bottom: 20px; } .fourcolumn_piece { display: inline-block; margin-left: 35px; margin-top: 8px; padding: 0; vertical-align: top; width: 21.3%; } div.fourcolumn_piece ul { list-style-type: none; padding-left: 0px; margin-top: 2px; } div.fourcolumn_piece p { margin-bottom: 7px; color: #40444D; text-decoration: none; font-weight: bold; } div.fourcolumn_piece li { padding-left: 0px; margin-bottom: 5px; } div.fourcolumn_piece a { font-weight: normal; } content-hub-0.0+14.04.20140415/doc/qml/css/reset.css0000644000015301777760000000153312323326002022152 0ustar pbusernogroup00000000000000/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html version: 3.3.0 build: 3167 */ html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}content-hub-0.0+14.04.20140415/doc/qml/css/scratch.css0000644000015301777760000000137412323326002022462 0ustar pbusernogroup00000000000000body { margin: 0; } div.toc ul { padding: 0; } div.toc li { margin-bottom: 3px; } h1.title { font-size: 36px; line-height: 1.1; font-weight: normal; } h0, h2 { font-size: 24px; line-height: 1.2; margin: 14px 0; font-weight: normal; display: block; } a:hover { color: #dd4814; text-decoration: underline; outline: 0; } table, pre { border-radius: 0; } .annotated td { padding: 0.8em 1em 0.3em; } .wrapper { width: 940px; margin: 0 auto; } .main-content { width: 668px; position: relative; left: 270px; } .title { margin-left: -270px; margin-top: 30px; margin-bottom: 50px; } .toc { margin-left: -270px; font-size: 100%; margin-bottom: 40px; padding: 0; z-index: 2; position: absolute; top: 100px; width: 250px; } content-hub-0.0+14.04.20140415/doc/qml/css/base.css0000644000015301777760000002706712323326002021754 0ustar pbusernogroup00000000000000/** * Ubuntu Developer base stylesheet * * A base stylesheet containing site-wide styles * * @project Ubuntu Developer * @version 1.0 * @author Canonical Web Team: Steve Edwards * @copyright 2011 Canonical Ltd. */ /** * @section Global */ body { font-family: 'Ubuntu', 'Ubuntu Beta', UbuntuBeta, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 13px; line-height: 1.4; color: #333; } a { color: #dd4814; text-decoration: none; outline: 0; } p, dl { margin-bottom: 10px; } strong { font-weight: bold; } em { font-style: italic; } code{ padding: 10px; font-family: 'Ubuntu Mono', 'Consolas', 'Monaco', 'DejaVu Sans Mono', Courier, monospace; background-color: #fdf6f2; display: block; margin-bottom: 10px; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } h1 { font-size: 36px; line-height: 1.1; margin-bottom: 20px; } article h1, h2 { font-size: 24px; line-height: 1.2; margin-bottom: 14px; } h3 { font-size: 16px; line-height: 1.3; margin-bottom: 8px; } h4 { font-weight: bold; } time { color:#999; } /** * @section Structure */ .header-login, .header-navigation div, .header-content div { margin: 0 auto; width: 940px; } .header-content h1{ background-color:#ffffff; display:inline-block; } .header-content h2{ background-color:#ffffff; display:table; } .header-login ul { margin: 4px 0; float: right; } .header-login li { margin-right: 10px; float: left; } .header-login a { color: #333; } .header-navigation { border-top: 2px solid #dd4814; border-bottom: 2px solid #dd4814; background-color: #fff; height: 54px; clear: right; overflow: hidden; } .header-navigation nav ul { border-right: 1px solid #dd4814; float: right; } .header-navigation nav li { border-left: 1px solid #dd4814; float: left; height: 54px; } .header-navigation nav a { padding: 18px 14px 0; font-size: 14px; display: block; height: 36px; } .header-navigation nav a:hover { background-color: #fcece7; } .header-navigation nav .current_page_item a, .header-navigation nav .current_page_parent a, .header-navigation nav .current_page_ancestor a { background-color: #dd4814; color: #fff; } .header-navigation input { margin: 12px 10px 0 10px; padding: 5px; border-top: 1px solid #a1a1a1; border-right: 1px solid #e0e0e0; border-bottom: 1px solid #fff; border-left: 1px solid #e0e0e0; width: 90px; font-style: italic; color: #ccc; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; -moz-box-shadow: inset 0 1px 1px #e0e0e0; -webkit-box-shadow: inset 0 1px 1px #e0e0e0; box-shadow: inset 0 1px 1px #e0e0e0; } .header-navigation h2 { margin: 18px 0 0 6px; text-transform: lowercase; font-size: 22px; color: #dd4814; float: left; } .header-navigation .logo-ubuntu { margin-top: 12px; float: left; } .header-content .header-navigation-secondary { margin-bottom: 40px; padding: 0; position: relative; z-index: 2; } .header-navigation-secondary div { padding: 0; border: 2px solid #dd4814; -moz-border-radius: 0px 0px 4px 4px; -webkit-border-radius: 0px 0px 4px 4px; border-radius: 0px 0px 4px 4px; background: #fff; border-top: 0px; width: 936px; } .header-navigation-secondary nav li { float: left; } .header-navigation-secondary nav li a { color: #333; display: block; height: 25px; padding: 8px 8px 0; } .header-navigation-secondary nav li:hover, .header-navigation-secondary nav .current_page_item a { background: url("../img/sec-nav-hover.gif"); } .header-content { padding-bottom: 30px; border-bottom: 1px solid #e0e0e0; -moz-box-shadow: 0 1px 3px #e0e0e0; -webkit-box-shadow: 0 1px 3px #e0e0e0; box-shadow: 0 1px 3px #e0e0e0; margin-bottom: 3px; position: relative; overflow: hidden; } footer { padding: 10px 10px 40px 10px; position: relative; -moz-border-radius: 0 0 4px 4px; -webkit-border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px; font-size: 12px; background: url("../img/background-footer.png") repeat scroll 0 0 #f7f6f5; } footer div { margin: 0 auto; padding: 0 10px; width: 940px; } footer a { color: #000; } footer nav ul { margin: 10px 17px 30px 0; width: 172px; display: inline-block; vertical-align: top; height: auto; zoom: 1; *display: inline; } footer nav ul.last { margin-right: 0; } footer nav li { margin-bottom: 8px; } footer nav li:first-child { font-weight: bold; } footer p { margin-bottom: 0; } #content { padding-top: 35px; } .arrow-nav { display: none; position: absolute; top: -1px; z-index: 3; } .shadow { margin: 30px 0 3px 0; border-bottom: 1px solid #e0e0e0; -moz-box-shadow: 0 2px 3px #e0e0e0; -webkit-box-shadow: 0 2px 3px #e0e0e0; box-shadow: 0 2px 3px #e0e0e0; height: 3px; } /** * @section Site-wide */ #content h2{ font-size:24px; } .box-orange { padding: 10px; border: 3px solid #dd4814; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } .box-orange .link-action-small { float: right; margin: 0 0 0 20px; } .link-bug { margin-left: 10px; color: #999; } .link-action { float: left; margin-bottom: 20px; padding: 8px 12px; display: block; background-color: #dd4814; color: #fff; -moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px; font-size: 16px; line-height: 1.3; border-top: 3px solid #e6633a; border-bottom: 3px solid #c03d14; } .link-action2 { float: left; display: block; color: #fff; font-size: 16px; line-height: 1.3; } .link-action2 span{ display:block; float:left; } .link-action2 .cta-left{ background:url(../img/button-cta-left.png) no-repeat; width:22px; height:48px; } .link-action2 .cta-center{ background:url(../img/button-cta-slice.png) repeat-x; line-height:45px; height:48px; } .link-action2 .cta-right{ background:url(../img/button-cta-right.png) no-repeat; width:22px; height:48px; } .link-action-small { float: left; display: block; color: #fff; font-size: 16px; } .link-action-small span{ display:block; float:left; height:42px; } .link-action-small .cta-left{ background:url(../img/button-cta-left-small.png) no-repeat; width:19px; } .link-action-small .cta-center{ background:url(../img/button-cta-slice-small.png) repeat-x; line-height:42px; } .link-action-small .cta-right{ background:url(../img/button-cta-right-small.png) no-repeat; width:19px; } .link-action:active { position: relative; top: 1px; } .link-action2:active { position: relative; top: 1px; } .link-action-small:active { position: relative; top: 1px; } .list-bullets li { margin-bottom: 10px; list-style: disc; list-style-position: inside; } .box { margin-bottom: 30px; padding: 15px; border: 1px solid #aea79f; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } .box-padded { margin-bottom: 30px; padding: 5px; border: 2px solid #aea79f; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; background: url("../img/pattern-featured.gif") repeat scroll 0 0 #ebe9e7; overflow: hidden; } .box-padded h3 { margin: 5px 0 10px 5px; } .box-padded div { padding: 10px; border: 1px solid #aea79f; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; background-color: #fff; overflow: hidden; } .box-padded li { padding: 0 10px; float: left; width: 211px; border-right: 1px dotted #aea79f; } .box-padded li.first { padding: 0; margin-bottom: 0; } .box-padded li.last { border: 0; width: 217px; } .box-padded img { margin: 0 10px 50px 0; float: left; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; } .box-clear { margin-bottom: 40px; } .box-clear .grid-4.first { margin-right: 15px; padding-right: 15px; } .box-clear .grid-4 { margin-left: 0; margin-right: 10px; padding-right: 10px; width: 298px; } .box-clear time { display: block; border-bottom: 1px dotted #aea79f; padding-bottom: 10px; margin-bottom: 10px; } .box-clear div.first { border-right: 1px dotted #aea79f; } .box-clear a { display: block; } .box-clear .rss { background: url("../img/rss.jpg") no-repeat scroll 0 center; padding-left: 20px; } .box-clear .location { display: block; margin-bottom: 1px; } .box-clear .last { margin: 0; padding-right: 0; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; width: 293px; } /* Widgets */ .ui-state-focus { outline: none; } .ui-accordion { border-bottom: 1px dotted #aea79f; } .ui-accordion a { display: block; } .ui-accordion h3 { margin-bottom: 0; border-top: 1px dotted #aea79f; position: relative; font-size: 13px; font-weight: bold; } .ui-accordion h3 a { padding: 10px 0; color: #333; } .ui-accordion h4 { margin-bottom: 5px; } .ui-accordion div fieldset { padding-bottom: 5px; } .ui-accordion div li, .ui-accordion div input { margin-bottom: 10px; } .ui-accordion .ui-icon { position: absolute; top: 15px; right: 0; display: block; width: 8px; height: 8px; background: url("../img/icon-accordion-inactive.png") 0 0 no-repeat transparent; } .ui-accordion .ui-state-active .ui-icon { background-image: url("../img/icon-accordion-active.png"); } .ui-accordion .current_page_item a { color: #333; } .container-tweet { -moz-border-radius: 4px 4px 4px 4px; -webkit-border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px; padding: 10px 10px 10px; background-color: #f7f7f7; } .container-tweet .tweet-follow { margin-top: 10px; margin-bottom: -10px; padding-left: 55px; padding-bottom: 6px; background: url("../img/tweet-follow.png") 0 5px no-repeat; display: block; } .container-tweet .tweet-follow span { font-size: 16px; font-weight: bold; line-height: 1.2; display: block; } .tweet a { display: inline; } .tweet .tweet_text { padding: 10px; background-color: #fff; -moz-border-radius: 4px 4px 4px 4px; -webkit-border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px; border: 1px solid #dd4814; font-size: 16px; display: block; clear: both; } .tweet.tweet-small .tweet_text { font-size: inherit; } .tweet .tweet_text a { color: #333; } .tweet .tweet_time, .tweet .tweet_user_and_time { padding: 15px 0 10px 0; position: relative; top: -2px; background: url("../img/tweet-arrow.png") no-repeat; display: block; } .tweet .tweet_odd .tweet_time, .tweet .tweet_odd .tweet_user_and_time { background-position: right 0; float: right; } .tweet .tweet_even .tweet_time, .tweet .tweet_even .tweet_user_and_time { background-position: left 0; float: left; } /* Search */ #content .list-search li { list-style-type:none; border:0px; margin-bottom: 15px; padding-top: 15px; } /* Blog */ .blog-article #nav-single { margin-top: 30px; margin-bottom: 30px; } .blog-article #nav-single .nav-next { float: right; } .blog-article article header .entry-meta { margin-bottom: 20px; } .blog-article article .entry-meta { color: #999; } .blog-article #respond form input[type="submit"] { float: left; cursor: pointer; margin-bottom: 20px; padding: 8px 12px; display: block; background-color: #dd4814; color: #fff; -moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px; font-size: 16px; line-height: 1.3; border-top: 3px solid #e6633a; border-left: 3px solid #e6633a; border-right: 3px solid #e6633a; border-bottom: 3px solid #c03d14; } .blog-article #respond form input[type="submit"]:active { position: relative; top: 1px; } .alignnone{ float:left; margin:10px 20px 10px 0; } .alignleft{ float:left; margin:10px 20px 10px 0; } .alignright{ float:right; margin:10px 0 10px 20px; } .aligncenter{ float:left; margin:10px 20px 10px 0; } .entry-content h2, .entry-content h3{ margin-top:20px; } .entry-content ul li{ list-style-type: circle; margin-left:16px; } .entry-content hr{ border:none; border-top: 1px dotted #AEA79F; } content-hub-0.0+14.04.20140415/libcontent-hub.pc.in0000644000015301777760000000037712323326002022043 0ustar pbusernogroup00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=${prefix}/include Name: @pkg-name@ Description: content sharing/picking library Version: @CONTENT_HUB_VERSION@ Libs: -L${libdir} -lcontent-hub Cflags: -I${includedir} Requires: Qt5DBus content-hub-0.0+14.04.20140415/CMakeLists.txt0000644000015301777760000001000012323326002020715 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss cmake_minimum_required(VERSION 2.8) project(content-hub) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include (GNUInstallDirs) include (EnableCoverageReport) include (GSettings) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -pedantic -Wextra -fPIC -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -fno-strict-aliasing -pedantic -Wextra -fPIC -pthread") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # 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(pkglibexecdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}") ##################################################################### # Enable code coverage calculation with gcov/gcovr/lcov # Usage: # * Switch build type to coverage (use ccmake or cmake-gui) # * Invoke make, make test, make coverage # * Find html report in subdir coveragereport # * Find xml report feasible for jenkins in coverage.xml ##################################################################### IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) enable_testing() set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(Qt5Core) find_package(Qt5DBus) find_package(PkgConfig REQUIRED) pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(GIO REQUIRED gio-unix-2.0) pkg_check_modules(UPSTART_LAUNCH REQUIRED upstart-app-launch-2) pkg_check_modules(GSETTINGS REQUIRED gsettings-qt) pkg_check_modules(NIH REQUIRED libnih) pkg_check_modules(NIH_DBUS REQUIRED libnih-dbus) pkg_check_modules(DBUS REQUIRED dbus-1) add_definitions( -DDEBUG_ENABLED ) set(CONTENT_HUB_VERSION_MAJOR 0) set(CONTENT_HUB_VERSION_MINOR 0) set(CONTENT_HUB_VERSION_PATCH 1) set(CONTENT_HUB_VERSION "${CONTENT_HUB_VERSION_MAJOR}.${CONTENT_HUB_VERSION_MINOR}.${CONTENT_HUB_VERSION_PATCH}") include_directories(include) add_subdirectory(doc) add_subdirectory(src) add_subdirectory(import) add_subdirectory(examples) add_subdirectory(tests) install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) # Build and install a pkg-config file set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${prefix}/bin) set(libdir ${prefix}/${CMAKE_INSTALL_LIBDIR}) set(pkg-name "libcontent-hub") configure_file(libcontent-hub.pc.in libcontent-hub.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcontent-hub.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # There's no nice way to format this. Thanks CMake. add_test(LGPL-required /bin/sh -c "! grep -rl 'GNU General' ${PROJECT_SOURCE_DIR}/src/client ${PROJECT_SOURCE_DIR}/include/client ${PROJECT_SOURCE_DIR}/src/shared ${PROJECT_SOURCE_DIR}/include/shared" ) add_test(GPL-required /bin/sh -c "! grep -rl 'GNU Lesser' ${PROJECT_SOURCE_DIR}/src/server ${PROJECT_SOURCE_DIR}/include/server ${PROJECT_SOURCE_DIR}/include/test ${PROJECT_SOURCE_DIR}/tests ${PROJECT_SOURCE_DIR}/examples" ) content-hub-0.0+14.04.20140415/src/0000755000015301777760000000000012323326474016772 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/CMakeLists.txt0000644000015301777760000000125612323326002021521 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss add_subdirectory(com)content-hub-0.0+14.04.20140415/src/com/0000755000015301777760000000000012323326474017550 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/0000755000015301777760000000000012323326474021072 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/applicationmanager/0000755000015301777760000000000012323326474024730 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/applicationmanager/application_manager.h0000644000015301777760000000357712323326002031075 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #ifndef COM_UBUNTU_APPLICATION_MANAGER_H_ #define COM_UBUNTU_APPLICATION_MANAGER_H_ #include namespace com { namespace ubuntu { namespace ApplicationManager { class ApplicationManager { public: ApplicationManager() = default; ApplicationManager(const ApplicationManager&) = default; virtual ~ApplicationManager() = default; ApplicationManager& operator=(const ApplicationManager&) = default; /*! * \brief invoke_application starts an application, and brings it to foreground * \param app_id ID for the application (for example "gallery-app" - used for the desktop) */ virtual bool invoke_application(const std::string &app_id) = 0; /*! * \brief stop_application stops an application started by upstart * \param app_id ID for the application (for example "gallery-app" - used for the desktop) */ virtual bool stop_application(const std::string &app_id) = 0; /*! * \brief is_application_started returns true, if the application s already started by upstart * \param app_id ID for the application (for example "gallery-app" - used for the desktop) */ virtual bool is_application_started(const std::string &app_id) = 0; }; } } } #endif // COM_UBUNTU_APPLICATION_MANAGER_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/0000755000015301777760000000000012323326474022544 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/0000755000015301777760000000000012323326474024006 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/app_manager.h0000644000015301777760000000252312323326002026416 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #ifndef COM_UBUNTU_APP_MANAGER_H_ #define COM_UBUNTU_APP_MANAGER_H_ #include namespace com { namespace ubuntu { namespace content { namespace detail { class AppManager: public com::ubuntu::ApplicationManager::ApplicationManager { public: AppManager() = default; AppManager(const AppManager&) = default; virtual ~AppManager() = default; AppManager& operator=(const AppManager&) = default; virtual bool invoke_application(const std::string &app_id); virtual bool stop_application(const std::string &app_id); virtual bool is_application_started(const std::string &app_id); }; } } } } #endif // COM_UBUNTU_APPLICATION_MANAGER_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/transfer.h0000644000015301777760000000437212323326002025774 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef TRANSFER_H_ #define TRANSFER_H_ #include #include namespace com { namespace ubuntu { namespace content { namespace detail { class Transfer : public QObject { Q_OBJECT Q_PROPERTY(int State READ State NOTIFY StateChanged) Q_PROPERTY(QString Store READ Store WRITE SetStore NOTIFY StoreChanged) Q_PROPERTY(int SelectionType READ SelectionType WRITE SetSelectionType NOTIFY SelectionTypeChanged) Q_PROPERTY(int id READ Id) Q_PROPERTY(QString source READ source) Q_PROPERTY(QString destination READ destination) Q_PROPERTY(int direction READ Direction) public: Transfer(const int, const QString&, const QString&, const int, QObject* parent = nullptr); Transfer(const Transfer&) = delete; virtual ~Transfer(); Transfer& operator=(const Transfer&) = delete; void SetSourceStartedByContentHub(bool started); bool WasSourceStartedByContentHub() const; Q_SIGNALS: void StateChanged(int State); void StoreChanged(QString Store); void SelectionTypeChanged(int SelectionType); public Q_SLOTS: int State(); void Start(); void Handled(); void Charge(const QStringList&); QStringList Collect(); void Abort(); void Finalize(); QString Store(); void SetStore(QString); int SelectionType(); void SetSelectionType(int); int Id(); int Direction(); QString source(); QString destination(); QString export_path(); QString import_path(); private: struct Private; QScopedPointer d; }; } } } } #endif // TRANSFER_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml0000644000015301777760000000254112323326002032050 0ustar pbusernogroup00000000000000 content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/service.h0000644000015301777760000000475312323326002025613 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef SERVICE_H_ #define SERVICE_H_ #include #include #include #include #include #include #include #include #include "handler.h" namespace com { namespace ubuntu { namespace content { namespace detail { class PeerRegistry; class Service : public QObject, protected QDBusContext { Q_OBJECT public: Service(QDBusConnection connection, const QSharedPointer& registry, QSharedPointer& application_manager, QObject* parent = nullptr); Service(const Service&) = delete; ~Service(); Service& operator=(const Service&) = delete; public Q_SLOTS: QDBusVariant DefaultSourceForType(const QString &type_id); QVariantList KnownSourcesForType(const QString &type_id); QVariantList KnownDestinationsForType(const QString &type_id); QVariantList KnownSharesForType(const QString &type_id); QDBusObjectPath CreateImportFromPeer(const QString&, const QString&); QDBusObjectPath CreateExportToPeer(const QString&, const QString&); QDBusObjectPath CreateShareToPeer(const QString&, const QString&); void RegisterImportExportHandler(const QString&, const QDBusObjectPath& handler); void Quit(); private: bool should_cancel(int); struct Private; struct RegHandler; QDBusServiceWatcher* m_watcher; QScopedPointer d; private Q_SLOTS: void handle_imports(int); void handle_exports(int); void handler_unregistered(const QString&); QDBusObjectPath CreateTransfer(const QString&, const QString&, int); }; } } } } #endif // SERVICE_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/transfer.cpp0000644000015301777760000001421412323326002026323 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include "debug.h" #include "transfer.h" #include "utils.cpp" #include #include #include namespace cuc = com::ubuntu::content; namespace cucd = com::ubuntu::content::detail; struct cucd::Transfer::Private { Private(const int id, const QString& source, const QString& destination, const int direction) : state(cuc::Transfer::created), id(id), source(source), destination(destination), direction(direction), selection_type(cuc::Transfer::single), source_started_by_content_hub(false) { } cuc::Transfer::State state; const int id; const QString source; const QString destination; int direction; QString store; int selection_type; QStringList items; bool source_started_by_content_hub; }; cucd::Transfer::Transfer(const int id, const QString& source, const QString& destination, const int direction, QObject* parent) : QObject(parent), d(new Private(id, source, destination, direction)) { TRACE() << __PRETTY_FUNCTION__; } cucd::Transfer::~Transfer() { TRACE() << __PRETTY_FUNCTION__; purge_store_cache(d->store); } /* unique id of the transfer */ int cucd::Transfer::Id() { TRACE() << __PRETTY_FUNCTION__; return d->id; } /* returns the peer_id of the requested export handler */ QString cucd::Transfer::source() { TRACE() << __PRETTY_FUNCTION__; return d->source; } /* returns the peer_id of the application requesting the import */ QString cucd::Transfer::destination() { TRACE() << __PRETTY_FUNCTION__; return d->destination; } int cucd::Transfer::Direction() { TRACE() << __PRETTY_FUNCTION__; return d->direction; } int cucd::Transfer::State() { TRACE() << __PRETTY_FUNCTION__; return d->state; } void cucd::Transfer::Abort() { TRACE() << __PRETTY_FUNCTION__; if (d->state == cuc::Transfer::aborted) return; purge_store_cache(d->store); d->items.clear(); d->state = cuc::Transfer::aborted; Q_EMIT(StateChanged(d->state)); } void cucd::Transfer::Start() { TRACE() << __PRETTY_FUNCTION__; if (d->state == cuc::Transfer::initiated) return; d->state = cuc::Transfer::initiated; Q_EMIT(StateChanged(d->state)); } void cucd::Transfer::Handled() { TRACE() << __PRETTY_FUNCTION__; if (d->state == cuc::Transfer::in_progress) return; d->state = cuc::Transfer::in_progress; Q_EMIT(StateChanged(d->state)); } void cucd::Transfer::Charge(const QStringList& items) { TRACE() << __PRETTY_FUNCTION__; if (d->state == cuc::Transfer::charged) return; QStringList ret; Q_FOREACH(QString i, items) ret.append(copy_to_store(i, d->store)); Q_FOREACH(QString f, ret) TRACE() << Q_FUNC_INFO << "Item:" << f; if (ret.count() <= 0) { qWarning() << "Failed to charge items, aborting"; d->state = cuc::Transfer::aborted; } else { d->items = ret; d->state = cuc::Transfer::charged; } Q_EMIT(StateChanged(d->state)); } QStringList cucd::Transfer::Collect() { TRACE() << __PRETTY_FUNCTION__; if (d->state != cuc::Transfer::collected) { d->state = cuc::Transfer::collected; Q_EMIT(StateChanged(d->state)); } return d->items; } void cucd::Transfer::Finalize() { TRACE() << __PRETTY_FUNCTION__; if (d->state == cuc::Transfer::finalized) return; purge_store_cache(d->store); d->items.clear(); d->state = cuc::Transfer::finalized; Q_EMIT(StateChanged(d->state)); } QString cucd::Transfer::Store() { TRACE() << __PRETTY_FUNCTION__; return d->store; } void cucd::Transfer::SetStore(QString uri) { TRACE() << Q_FUNC_INFO; if (d->store == uri) return; d->store = uri; Q_EMIT(StoreChanged(d->store)); } int cucd::Transfer::SelectionType() { TRACE() << __PRETTY_FUNCTION__; return d->selection_type; } void cucd::Transfer::SetSelectionType(int type) { TRACE() << Q_FUNC_INFO; if (d->state != cuc::Transfer::created) return; if (d->selection_type == type) return; d->selection_type = type; Q_EMIT(SelectionTypeChanged(d->selection_type)); } /* returns the object path for the export */ QString cucd::Transfer::export_path() { TRACE() << Q_FUNC_INFO << "source:" << d->source; static const QString exporter_path_pattern{"/transfers/%1/export/%2"}; QString source = exporter_path_pattern .arg(sanitize_id(d->source)) .arg(d->id); return source; } /* returns the object path for the import */ QString cucd::Transfer::import_path() { TRACE() << Q_FUNC_INFO << "destination:" << d->destination; static const QString importer_path_pattern{"/transfers/%1/import/%2"}; QString destination = importer_path_pattern .arg(sanitize_id(d->destination)) .arg(d->id); return destination; } /* sets, if the source app is freshly started by the content hub */ void cucd::Transfer::SetSourceStartedByContentHub(bool started) { d->source_started_by_content_hub = started; } /* returns if the source app was started by the content hub */ bool com::ubuntu::content::detail::Transfer::WasSourceStartedByContentHub() const { return d->source_started_by_content_hub; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/app_manager.cpp0000644000015301777760000000276612323326002026762 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #include "app_manager.h" #include "debug.h" #include namespace cucd = com::ubuntu::content::detail; /*! * \reimp */ bool cucd::AppManager::invoke_application(const std::string &app_id) { TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str(); gchar ** uris = NULL; gboolean ok = upstart_app_launch_start_application(app_id.c_str(), (const gchar * const *)uris); return static_cast(ok); } /*! * \reimp */ bool cucd::AppManager::stop_application(const std::string &app_id) { TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str(); gboolean ok = upstart_app_launch_stop_application(app_id.c_str()); return static_cast(ok); } /*! * \reimp */ bool cucd::AppManager::is_application_started(const std::string &app_id) { GPid pid = upstart_app_launch_get_primary_pid(app_id.c_str()); return pid != 0; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/peer_registry.h0000644000015301777760000000365112323326002027032 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef PEER_REGISTRY_H_ #define PEER_REGISTRY_H_ #include #include #include namespace com { namespace ubuntu { namespace content { namespace detail { class PeerRegistry { public: PeerRegistry() = default; PeerRegistry(const PeerRegistry& registry) = delete; virtual ~PeerRegistry() = default; PeerRegistry& operator=(const PeerRegistry&) = delete; virtual Peer default_source_for_type(Type) = 0; virtual void enumerate_known_peers(const std::function& for_each) = 0; virtual void enumerate_known_sources_for_type(Type, const std::function& for_each) = 0; virtual void enumerate_known_destinations_for_type(Type, const std::function& for_each) = 0; virtual void enumerate_known_shares_for_type(Type, const std::function& for_each) = 0; virtual bool install_default_source_for_type(Type, Peer) = 0; virtual bool install_source_for_type(Type, Peer) = 0; virtual bool install_destination_for_type(Type, Peer) = 0; virtual bool install_share_for_type(Type, Peer) = 0; virtual bool remove_peer(Peer peer) = 0; }; } } } } #endif // PEER_REGISTRY_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/handler.cpp0000644000015301777760000000500612323326002026113 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Ken VanDine */ #include "transfer_p.h" #include "handler.h" #include "utils.cpp" #include "debug.h" #include namespace cucd = com::ubuntu::content::detail; namespace cuc = com::ubuntu::content; struct cucd::Handler::Private : public QObject { Private(QDBusConnection connection, const QString& peer_id, QObject* parent) : QObject(parent), connection(connection), peer_id(peer_id) { TRACE() << Q_FUNC_INFO; } QDBusConnection connection; const QString peer_id; }; cucd::Handler::Handler(QDBusConnection connection, const QString& peer_id, cuc::ImportExportHandler* handler) : d(new Private{connection, peer_id, this}) { TRACE() << Q_FUNC_INFO; m_handler = handler; } cucd::Handler::~Handler() { delete m_handler; } void cucd::Handler::HandleImport(const QDBusObjectPath& transfer) { TRACE() << Q_FUNC_INFO << transfer.path(); cuc::Transfer* t = cuc::Transfer::Private::make_transfer(transfer, this); TRACE() << Q_FUNC_INFO << "State:" << t->state(); if (t->state() == cuc::Transfer::charged) m_handler->handle_import(t); } void cucd::Handler::HandleExport(const QDBusObjectPath& transfer) { TRACE() << Q_FUNC_INFO << transfer.path(); cuc::Transfer* t = cuc::Transfer::Private::make_transfer(transfer, this); TRACE() << Q_FUNC_INFO << "State:" << t->state(); if (t->state() == cuc::Transfer::initiated) { t->d->handled(); m_handler->handle_export(t); } } void cucd::Handler::HandleShare(const QDBusObjectPath& transfer) { TRACE() << Q_FUNC_INFO; cuc::Transfer* t = cuc::Transfer::Private::make_transfer(transfer, this); TRACE() << Q_FUNC_INFO << "State:" << t->state(); if (t->state() == cuc::Transfer::charged) { m_handler->handle_share(t); } } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/com.ubuntu.content.Handler.xml0000644000015301777760000000057612323326002031647 0ustar pbusernogroup00000000000000 content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/handler.h0000644000015301777760000000312012323326002025553 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Ken VanDine */ #ifndef HANDLER_H_ #define HANDLER_H_ #include #include #include #include namespace com { namespace ubuntu { namespace content { namespace detail { class Handler : public QObject { Q_OBJECT public: Handler(QDBusConnection connection, const QString& peer_id, com::ubuntu::content::ImportExportHandler *handler = nullptr); Handler(const Handler&) = delete; ~Handler(); Handler& operator=(const Handler&) = delete; public Q_SLOTS: void HandleImport(const QDBusObjectPath &transfer); void HandleExport(const QDBusObjectPath &transfer); void HandleShare(const QDBusObjectPath &transfer); private: struct Private; QScopedPointer d; com::ubuntu::content::ImportExportHandler *m_handler; }; } } } } #endif // HANDLER_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml0000644000015301777760000000310012323326002031654 0ustar pbusernogroup00000000000000 content-hub-0.0+14.04.20140415/src/com/ubuntu/content/detail/service.cpp0000644000015301777760000003737012323326002026147 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include "debug.h" #include "service.h" #include "peer_registry.h" #include "transfer.h" #include "transferadaptor.h" #include "utils.cpp" #include "ContentHandlerInterface.h" #include #include #include #include #include #include #include #include #include #include namespace cua = com::ubuntu::ApplicationManager; namespace cucd = com::ubuntu::content::detail; namespace cuc = com::ubuntu::content; struct cucd::Service::RegHandler { RegHandler(QString id, QString service, cuc::dbus::Handler* handler) : id(id), service(service), handler(handler) { } QString id; QString service; cuc::dbus::Handler* handler; }; struct cucd::Service::Private : public QObject { Private(QDBusConnection connection, const QSharedPointer& registry, QSharedPointer& application_manager, QObject* parent) : QObject(parent), connection(connection), registry(registry), app_manager(application_manager) { } QDBusConnection connection; QSharedPointer registry; QSet active_transfers; QSet handlers; QSharedPointer app_manager; }; cucd::Service::Service(QDBusConnection connection, const QSharedPointer& peer_registry, QSharedPointer& application_manager, QObject* parent) : QObject(parent), m_watcher(new QDBusServiceWatcher()), d(new Private{connection, peer_registry, application_manager, this}) { assert(!peer_registry.isNull()); qDBusRegisterMetaType(); m_watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); m_watcher->setConnection(d->connection); QObject::connect(m_watcher, SIGNAL(serviceUnregistered(const QString&)), this, SLOT(handler_unregistered(const QString&))); } cucd::Service::~Service() { TRACE() << Q_FUNC_INFO; Q_FOREACH (cucd::Transfer *t, d->active_transfers) { TRACE() << Q_FUNC_INFO << "Destroying transfer:" << t->Id(); delete t; } } void cucd::Service::Quit() { QCoreApplication::instance()->quit(); } QVariantList cucd::Service::KnownSourcesForType(const QString& type_id) { QVariantList result; d->registry->enumerate_known_sources_for_type( Type(type_id), [&result](const Peer& peer) { result.append(QVariant::fromValue(peer)); }); return result; } QVariantList cucd::Service::KnownDestinationsForType(const QString& type_id) { QVariantList result; d->registry->enumerate_known_destinations_for_type( Type(type_id), [&result](const Peer& peer) { result.append(QVariant::fromValue(peer)); }); return result; } QVariantList cucd::Service::KnownSharesForType(const QString& type_id) { QVariantList result; d->registry->enumerate_known_shares_for_type( Type(type_id), [&result](const Peer& peer) { result.append(QVariant::fromValue(peer)); }); return result; } QDBusVariant cucd::Service::DefaultSourceForType(const QString& type_id) { cuc::Peer peer = d->registry->default_source_for_type(Type(type_id)); return QDBusVariant(QVariant::fromValue(peer)); } QDBusObjectPath cucd::Service::CreateImportFromPeer(const QString& peer_id, const QString& app_id) { TRACE() << Q_FUNC_INFO; QString dest_id = app_id; if (dest_id.isEmpty()) { TRACE() << Q_FUNC_INFO << "APP_ID isnt' set, attempting to get it from AppArmor"; dest_id = aa_profile(this->message().service()); } return CreateTransfer(dest_id, peer_id, cuc::Transfer::Import); } bool cucd::Service::should_cancel (int st) { TRACE() << Q_FUNC_INFO << "State:" << st; return (st != cuc::Transfer::finalized && st != cuc::Transfer::collected && st != cuc::Transfer::aborted); } QDBusObjectPath cucd::Service::CreateExportToPeer(const QString& peer_id, const QString& app_id) { TRACE() << Q_FUNC_INFO; QString src_id = app_id; if (src_id.isEmpty()) { TRACE() << Q_FUNC_INFO << "APP_ID isnt' set, attempting to get it from AppArmor"; src_id = aa_profile(this->message().service()); } return CreateTransfer(peer_id, src_id, cuc::Transfer::Export); } QDBusObjectPath cucd::Service::CreateShareToPeer(const QString& peer_id, const QString& app_id) { TRACE() << Q_FUNC_INFO; QString src_id = app_id; if (src_id.isEmpty()) { TRACE() << Q_FUNC_INFO << "APP_ID isnt' set, attempting to get it from AppArmor"; src_id = aa_profile(this->message().service()); } return CreateTransfer(peer_id, src_id, cuc::Transfer::Share); } QDBusObjectPath cucd::Service::CreateTransfer(const QString& dest_id, const QString& src_id, int dir) { TRACE() << Q_FUNC_INFO << "DEST:" << dest_id << "SRC:" << src_id << "DIRECTION:" << dir; static size_t import_counter{0}; import_counter++; QUuid uuid{QUuid::createUuid()}; Q_FOREACH (cucd::Transfer *t, d->active_transfers) { if (t->destination() == dest_id || t->source() == src_id) { TRACE() << Q_FUNC_INFO << "Found transfer for peer_id:" << src_id; if (should_cancel(t->State())) { TRACE() << Q_FUNC_INFO << "Aborting active transfer:" << t->Id(); t->Abort(); } } } auto transfer = new cucd::Transfer(import_counter, src_id, dest_id, dir, this); new TransferAdaptor(transfer); d->active_transfers.insert(transfer); auto destination = transfer->import_path(); auto source = transfer->export_path(); if (not d->connection.registerObject(source, transfer)) TRACE() << "Problem registering object for path: " << source; d->connection.registerObject(destination, transfer); TRACE() << "Created transfer " << source << " -> " << destination; // Content flow is different for import if (dir == cuc::Transfer::Import) { connect(transfer, SIGNAL(StateChanged(int)), this, SLOT(handle_imports(int))); return QDBusObjectPath{destination}; } connect(transfer, SIGNAL(StateChanged(int)), this, SLOT(handle_exports(int))); return QDBusObjectPath{source}; } void cucd::Service::handle_imports(int state) { TRACE() << Q_FUNC_INFO << state; cucd::Transfer *transfer = static_cast(sender()); TRACE() << Q_FUNC_INFO << "State: " << transfer->State() << "Id:" << transfer->Id(); if (state == cuc::Transfer::initiated) { TRACE() << Q_FUNC_INFO << "initiated"; if (d->app_manager->is_application_started(transfer->source().toStdString())) transfer->SetSourceStartedByContentHub(false); else transfer->SetSourceStartedByContentHub(true); Q_FOREACH (RegHandler *r, d->handlers) { TRACE() << Q_FUNC_INFO << "ID:" << r->id << "Handler: " << r->service << "Transfer: " << transfer->source(); if (r->id == transfer->source()) { TRACE() << Q_FUNC_INFO << "Found handler for initiated transfer" << r->id; if (r->handler->isValid()) r->handler->HandleExport(QDBusObjectPath{transfer->export_path()}); else TRACE() << Q_FUNC_INFO << "Handler invalid"; } } d->app_manager->invoke_application(transfer->source().toStdString()); } if (state == cuc::Transfer::charged) { TRACE() << Q_FUNC_INFO << "Charged"; if (transfer->WasSourceStartedByContentHub()) d->app_manager->stop_application(transfer->source().toStdString()); d->app_manager->invoke_application(transfer->destination().toStdString()); Q_FOREACH (RegHandler *r, d->handlers) { TRACE() << Q_FUNC_INFO << "ID:" << r->id << "Handler: " << r->service << "Transfer: " << transfer->destination(); if (r->id == transfer->destination()) { TRACE() << Q_FUNC_INFO << "Found handler for charged transfer" << r->id; if (r->handler->isValid()) r->handler->HandleImport(QDBusObjectPath{transfer->import_path()}); } } } if (state == cuc::Transfer::aborted) { if (transfer->WasSourceStartedByContentHub()) { bool shouldStop = true; Q_FOREACH (cucd::Transfer *t, d->active_transfers) { if (t->Id() != transfer->Id()) { if ((t->source() == transfer->source()) && (t->State() == cuc::Transfer::in_progress)) { TRACE() << Q_FUNC_INFO << "Source has pending transfers:" << t->Id(); shouldStop = false; } if (t->destination() == transfer->destination()) { TRACE() << Q_FUNC_INFO << "Destination has pending transfers:" << t->Id(); if (should_cancel(t->State())) shouldStop = false; } } } if (shouldStop) d->app_manager->stop_application(transfer->source().toStdString()); } d->app_manager->invoke_application(transfer->destination().toStdString()); } } void cucd::Service::handle_exports(int state) { TRACE() << Q_FUNC_INFO; cucd::Transfer *transfer = static_cast(sender()); TRACE() << Q_FUNC_INFO << "STATE:" << transfer->State(); if (state == cuc::Transfer::initiated) { TRACE() << Q_FUNC_INFO << "Initiated"; transfer->Handled(); } if (state == cuc::Transfer::charged) { TRACE() << Q_FUNC_INFO << "Charged"; if (d->app_manager->is_application_started(transfer->destination().toStdString())) transfer->SetSourceStartedByContentHub(false); else transfer->SetSourceStartedByContentHub(true); d->app_manager->invoke_application(transfer->destination().toStdString()); Q_FOREACH (RegHandler *r, d->handlers) { TRACE() << "Handler: " << r->service << "Transfer: " << transfer->destination(); if (r->id == transfer->destination()) { TRACE() << "Found handler for charged transfer" << r->id; if (transfer->Direction() == cuc::Transfer::Share && r->handler->isValid()) r->handler->HandleShare(QDBusObjectPath{transfer->import_path()}); else if (r->handler->isValid()) r->handler->HandleImport(QDBusObjectPath{transfer->import_path()}); } } } if (state == cuc::Transfer::finalized) { TRACE() << Q_FUNC_INFO << "Finalized"; if (transfer->WasSourceStartedByContentHub()) d->app_manager->stop_application(transfer->destination().toStdString()); d->app_manager->invoke_application(transfer->source().toStdString()); } if (state == cuc::Transfer::aborted) { TRACE() << Q_FUNC_INFO << "Aborted"; if (transfer->WasSourceStartedByContentHub()) { bool shouldStop = true; Q_FOREACH (cucd::Transfer *t, d->active_transfers) { if (t->Id() != transfer->Id()) { if ((t->source() == transfer->source()) && (t->State() == cuc::Transfer::in_progress)) { TRACE() << Q_FUNC_INFO << "Source has pending transfers:" << t->Id(); shouldStop = false; } if (t->destination() == transfer->destination()) { TRACE() << Q_FUNC_INFO << "Destination has pending transfers:" << t->Id(); if (should_cancel(t->State())) shouldStop = false; } } } if (shouldStop) d->app_manager->stop_application(transfer->destination().toStdString()); } d->app_manager->invoke_application(transfer->source().toStdString()); } } void cucd::Service::handler_unregistered(const QString& s) { TRACE() << Q_FUNC_INFO << s; if (d->handlers.isEmpty()) return; Q_FOREACH (RegHandler *r, d->handlers) { TRACE() << "Handler: " << r->id; if (r->service == s) { TRACE() << "Found match for " << r->id; d->handlers.remove(r); m_watcher->removeWatchedService(s); delete r; } } } void cucd::Service::RegisterImportExportHandler(const QString& peer_id, const QDBusObjectPath& handler) { TRACE() << Q_FUNC_INFO << peer_id; bool exists = false; RegHandler* r; Q_FOREACH (RegHandler *rh, d->handlers) { TRACE() << "Handler: " << rh->id; if (rh->id == peer_id) { TRACE() << "Found existing handler for " << rh->id; exists = true; r = rh; } } if (!exists) { r = new RegHandler{peer_id, this->message().service(), new cuc::dbus::Handler( this->message().service(), handler.path(), QDBusConnection::sessionBus(), 0)}; d->handlers.insert(r); m_watcher->addWatchedService(r->service); } TRACE() << Q_FUNC_INFO << r->id; Q_FOREACH (cucd::Transfer *t, d->active_transfers) { TRACE() << Q_FUNC_INFO << "SOURCE: " << t->source() << "DEST:" << t->destination() << "STATE:" << t->State(); if ((t->source() == peer_id) && (t->State() == cuc::Transfer::initiated)) { TRACE() << Q_FUNC_INFO << "Found source:" << peer_id << "Direction:" << t->Direction(); if (t->Direction() == cuc::Transfer::Import) { if (r->handler->isValid()) r->handler->HandleExport(QDBusObjectPath{t->export_path()}); } } else if ((t->destination() == peer_id) && (t->State() == cuc::Transfer::charged)) { TRACE() << Q_FUNC_INFO << "Found destination:" << peer_id << "Direction:" << t->Direction(); if (t->Direction() == cuc::Transfer::Export) { TRACE() << Q_FUNC_INFO << "Found import, calling HandleImport"; if (r->handler->isValid()) r->handler->HandleImport(QDBusObjectPath{t->import_path()}); } else if (t->Direction() == cuc::Transfer::Share) { TRACE() << Q_FUNC_INFO << "Found share, calling HandleShare"; if (r->handler->isValid()) r->handler->HandleShare(QDBusObjectPath{t->import_path()}); } } } } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/transfer_p.h0000644000015301777760000001125112323326002025043 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_TRANSFER_P_H_ #define COM_UBUNTU_CONTENT_TRANSFER_P_H_ #include "common.h" #include "ContentTransferInterface.h" #include #include #include #include namespace com { namespace ubuntu { namespace content { class Transfer::Private : public QObject { Q_OBJECT public: static Transfer* make_transfer(const QDBusObjectPath& transfer, QObject* parent) { QSharedPointer d{new Private{transfer, parent}}; return new Transfer{d, parent}; } Private(const QDBusObjectPath& transfer, QObject* parent) : QObject(parent), remote_transfer( new com::ubuntu::content::dbus::Transfer( HUB_SERVICE_NAME, transfer.path(), QDBusConnection::sessionBus(), this)) { } int id() { auto reply = remote_transfer->Id(); reply.waitForFinished(); return reply.value(); } State state() { auto reply = remote_transfer->State(); reply.waitForFinished(); if (reply.isError()) return Transfer::aborted; return static_cast(reply.value()); } bool start() { auto reply = remote_transfer->Start(); reply.waitForFinished(); return not reply.isError(); } bool handled() { auto reply = remote_transfer->Handled(); reply.waitForFinished(); return not reply.isError(); } bool abort() { auto reply = remote_transfer->Abort(); reply.waitForFinished(); return not reply.isError(); } bool finalize() { auto reply = remote_transfer->Finalize(); reply.waitForFinished(); return not reply.isError(); } bool charge(const QVector& items) { QStringList l; Q_FOREACH(const Item& item, items) { l << item.url().toDisplayString(); } auto reply = remote_transfer->Charge(l); reply.waitForFinished(); return not reply.isError(); } QVector collect() { QVector result; auto reply = remote_transfer->Collect(); reply.waitForFinished(); if (reply.isError()) return result; Q_FOREACH(const QString& url, reply.value()) { result << Item(QUrl(url)); } return result; } Store store() { auto reply = remote_transfer->Store(); reply.waitForFinished(); /* FIXME: Return something if it fails */ /* if (reply.isError()) return new cuc::Store{""}; */ //return new Store{reply.value()}; return static_cast(reply.value()); } bool setStore(const Store* store) { auto reply = remote_transfer->SetStore(store->uri()); reply.waitForFinished(); return not reply.isError(); } SelectionType selection_type() { auto reply = remote_transfer->SelectionType(); reply.waitForFinished(); /* if SelectionType fails, default to single */ if (reply.isError()) return Transfer::SelectionType::single; return static_cast(reply.value()); } bool setSelectionType(int type) { auto reply = remote_transfer->SetSelectionType(type); reply.waitForFinished(); return not reply.isError(); } Direction direction() { auto reply = remote_transfer->Direction(); reply.waitForFinished(); /* if Direction fails, default to import */ if (reply.isError()) return Transfer::Direction::Import; return static_cast(reply.value()); } com::ubuntu::content::dbus::Transfer* remote_transfer; }; } } } #endif // COM_UBUNTU_CONTENT_TRANSFER_P_H_ content-hub-0.0+14.04.20140415/src/com/ubuntu/content/type.cpp0000644000015301777760000000366012323326002024221 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include #include namespace cuc = com::ubuntu::content; struct cuc::Type::Private { QString id; }; cuc::Type::Type(const QString& id, QObject* parent) : QObject(parent), d(new Private{id}) { } cuc::Type::Type(const cuc::Type& rhs) : QObject(rhs.parent()), d(rhs.d) { } cuc::Type::~Type() { } cuc::Type& cuc::Type::operator=(const cuc::Type& rhs) { d = rhs.d; return *this; } bool cuc::Type::operator==(const cuc::Type& rhs) const { if (d == rhs.d) return true; return d->id == rhs.d->id; } bool cuc::Type::operator<(const cuc::Type& rhs) const { return d->id < rhs.d->id; } const QString& cuc::Type::id() const { return d->id; } const cuc::Type& cuc::Type::unknown() { static cuc::Type t("unknown", nullptr); return t; } const cuc::Type& cuc::Type::Known::documents() { static cuc::Type t("documents", nullptr); return t; } const cuc::Type& cuc::Type::Known::pictures() { static cuc::Type t("pictures", nullptr); return t; } const cuc::Type& cuc::Type::Known::music() { static cuc::Type t("music", nullptr); return t; } const cuc::Type& cuc::Type::Known::contacts() { static cuc::Type t("contacts", nullptr); return t; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/debug.cpp0000644000015301777760000000140712323326002024323 0ustar pbusernogroup00000000000000/* * Copyright © 2014 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #include "debug.h" int appLoggingLevel = 1; // criticals void setLoggingLevel(int level) { appLoggingLevel = level; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/debug.h0000644000015301777760000000252212323326002023767 0ustar pbusernogroup00000000000000/* * Copyright © 2014 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #ifndef DEBUG_H #define DEBUG_H #include /* 0 - fatal, 1 - critical(default), 2 - info/debug */ extern int appLoggingLevel; static inline bool debugEnabled() { return appLoggingLevel >= 2; } static inline bool criticalsEnabled() { return appLoggingLevel >= 1; } static inline int loggingLevel() { return appLoggingLevel; } void setLoggingLevel(int level); #ifdef DEBUG_ENABLED #define TRACE() \ if (debugEnabled()) qDebug() << __FILE__ << __LINE__ << __func__ #define BLAME() \ if (criticalsEnabled()) qCritical() << __FILE__ << __LINE__ << __func__ #else #define TRACE() while (0) qDebug() #define BLAME() while (0) qDebug() #endif #endif // DEBUG_H content-hub-0.0+14.04.20140415/src/com/ubuntu/content/import_export_handler.cpp0000644000015301777760000000147412323326002027651 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . */ #include namespace cuc = com::ubuntu::content; cuc::ImportExportHandler::ImportExportHandler(QObject* parent) : QObject(parent) { } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/0000755000015301777760000000000012323326474024204 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/content-hub.hook.in0000644000015301777760000000021712323326002027704 0ustar pbusernogroup00000000000000Pattern: ${home}/.local/share/content-hub/${id} Exec: @pkglibexecdir@/content-hub/content-hub-peer-hook User-Level: yes Hook-Name: content-hub content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/registry.h0000644000015301777760000000401412323326002026207 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #ifndef REGISTRY_H #define REGISTRY_H #include #include #include #include "detail/peer_registry.h" namespace cucd = com::ubuntu::content::detail; namespace cuc = com::ubuntu::content; class Registry : public cucd::PeerRegistry { public: Registry(); ~Registry(); cuc::Peer default_source_for_type(cuc::Type type); void enumerate_known_peers(const std::function& for_each); void enumerate_known_sources_for_type(cuc::Type type, const std::function& for_each); void enumerate_known_destinations_for_type(cuc::Type type, const std::function& for_each); void enumerate_known_shares_for_type(cuc::Type type, const std::function& for_each); bool install_default_source_for_type(cuc::Type type, cuc::Peer peer); bool install_source_for_type(cuc::Type type, cuc::Peer peer); bool install_destination_for_type(cuc::Type type, cuc::Peer peer); bool install_share_for_type(cuc::Type type, cuc::Peer peer); bool remove_peer(cuc::Peer peer); private: QScopedPointer m_defaultSources; QScopedPointer m_sources; QScopedPointer m_dests; QScopedPointer m_shares; }; #endif // REGISTRY_H ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/com.ubuntu.content.dbus.Service.servicecontent-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/com.ubuntu.content.dbus.Service.servic0000644000015301777760000000012712323326002033507 0ustar pbusernogroup00000000000000[D-BUS Service] Name=com.ubuntu.content.dbus.Service Exec=/usr/bin/content-hub-service content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/com.ubuntu.content.hub.gschema.xml0000644000015301777760000000330712323326002032647 0ustar pbusernogroup00000000000000 ["com.ubuntu.gallery", "gallery", "current-user-version"] [] [] ["address-book-app", "", ""] [] [] [] [] [] [] [] [] [] [] [] [] content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/hook.cpp0000644000015301777760000001125512323326002025637 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include #include #include #include #include #include #include #include #include "debug.h" #include "hook.h" namespace cucd = com::ubuntu::content::detail; cucd::Hook::Hook(QObject *parent) : QObject(parent), registry(new Registry()) { QTimer::singleShot(200, this, SLOT(run())); } cucd::Hook::Hook(com::ubuntu::content::detail::PeerRegistry *registry, QObject *parent) : QObject(parent), registry(registry) { } void cucd::Hook::run() { TRACE() << Q_FUNC_INFO; /* Looks for files in ${HOME}/.local/share/content-hub/${id} installed * by click packages. These files are JSON, for example: * * { * "source": [ * "pictures", * "music" * ] * } * * The hook also iterates known peers and removes them if there is * no JSON file installed in this path. */ QDir contentDir( QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QString("/") + QString("content-hub")); if (not contentDir.exists()) return_error(); QStringList all_peers; registry->enumerate_known_peers([&all_peers](const com::ubuntu::content::Peer& peer) { all_peers.append(peer.id()); }); Q_FOREACH(QString p, all_peers) { TRACE() << Q_FUNC_INFO << "Looking for" << p; QStringList pp = contentDir.entryList(QStringList("*"+ p)); if (pp.isEmpty()) registry->remove_peer(com::ubuntu::content::Peer{p}); } Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files)) add_peer(f); QCoreApplication::instance()->quit(); } bool cucd::Hook::add_peer(QFileInfo result) { TRACE() << Q_FUNC_INFO << "Hook:" << result.filePath(); QStringList knownTypes; knownTypes << "pictures" << "music" << "contacts" << "documents"; QString app_id = result.fileName(); auto peer = cuc::Peer(app_id); QFile contentJson(result.absoluteFilePath()); if (!contentJson.open(QIODevice::ReadOnly | QIODevice::Text)) return_error("couldn't open " + result.absoluteFilePath()); QJsonParseError *e = new QJsonParseError(); QJsonDocument contentDoc = QJsonDocument::fromJson(contentJson.readAll(), e); if (e->error != 0) return return_error(e->errorString()); if (not contentDoc.isObject()) return return_error("invalid JSON object"); QJsonObject contentObj = contentDoc.object(); QVariant sources = contentObj.toVariantMap()["source"]; Q_FOREACH(QString k, sources.toStringList()) { if (knownTypes.contains(k)) { if (registry->install_source_for_type(cuc::Type{k}, peer)) TRACE() << "Installed source:" << peer.id() << "for type:" << k; } else qWarning() << "Failed to install" << peer.id() << "unknown type:" << k; } QVariant dests = contentObj.toVariantMap()["destination"]; Q_FOREACH(QString k, dests.toStringList()) { if (knownTypes.contains(k)) { if (registry->install_destination_for_type(cuc::Type{k}, peer)) TRACE() << "Installed destination:" << peer.id() << "for type:" << k; } else qWarning() << "Failed to install" << peer.id() << "unknown type:" << k; } QVariant shares = contentObj.toVariantMap()["share"]; Q_FOREACH(QString k, shares.toStringList()) { if (knownTypes.contains(k)) { if (registry->install_share_for_type(cuc::Type{k}, peer)) TRACE() << "Installed share:" << peer.id() << "for type:" << k; } else qWarning() << "Failed to install" << peer.id() << "unknown type:" << k; } return true; } bool cucd::Hook::return_error(QString err) { qWarning() << "Failed to install peer" << err; return false; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/helper.cpp0000644000015301777760000000333412323326002026155 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include #include #include #include "hook.h" #include "debug.h" namespace cuc = com::ubuntu::content; int main(int argc, char** argv) { QCoreApplication app(argc, argv); TRACE() << Q_FUNC_INFO; if (app.arguments().count() > 1) { qWarning() << "Shouldn't have arguments"; return 1; } /* read environment variables */ QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); if (environment.contains(QLatin1String("CONTENT_HUB_LOGGING_LEVEL"))) { bool isOk; int value = environment.value( QLatin1String("CONTENT_HUB_LOGGING_LEVEL")).toInt(&isOk); if (isOk) setLoggingLevel(value); } QDir contentDir( QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QString("/") + QString("content-hub")); if (!contentDir.exists()) { return 0; } new cuc::detail::Hook(); app.exec(); /* We always want to return 0 */ return 0; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/main.cpp0000644000015301777760000000536312323326002025626 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include #include #include #include "detail/app_manager.h" #include "debug.h" #include "common.h" #include "registry.h" #include "detail/service.h" #include "detail/peer_registry.h" #include "serviceadaptor.h" namespace cuca = com::ubuntu::ApplicationManager; namespace cucd = com::ubuntu::content::detail; namespace cuc = com::ubuntu::content; namespace { void shutdown(int sig) { TRACE() << Q_FUNC_INFO << sig; QCoreApplication::instance()->quit(); } } int main(int argc, char** argv) { int ret = 0; QCoreApplication *app = new QCoreApplication(argc, argv); /* read environment variables */ QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); if (environment.contains(QLatin1String("CONTENT_HUB_LOGGING_LEVEL"))) { bool isOk; int value = environment.value( QLatin1String("CONTENT_HUB_LOGGING_LEVEL")).toInt(&isOk); if (isOk) setLoggingLevel(value); } auto connection = QDBusConnection::sessionBus(); auto registry = QSharedPointer(new Registry()); auto app_manager = QSharedPointer(new cucd::AppManager()); auto server = new cucd::Service(connection, registry, app_manager, app->parent()); new ServiceAdaptor(server); if (not connection.registerService(HUB_SERVICE_NAME)) { qWarning() << "Failed to register" << HUB_SERVICE_NAME; ret = 1; } if (not connection.registerObject(HUB_SERVICE_PATH, server, QDBusConnection::ExportAdaptors)) { qWarning() << "Failed to register object on" << HUB_SERVICE_PATH; ret = 1; } std::signal(SIGTERM, shutdown); std::signal(SIGHUP, shutdown); std::signal(SIGKILL, shutdown); std::signal(SIGINT, shutdown); if (ret == 1) app->exit(ret); else ret = app->exec(); TRACE() << "Server exiting, cleaning up"; delete server; return ret; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/CMakeLists.txt0000644000015301777760000000440612323326002026733 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss include_directories(${CMAKE_CURRENT_BINARY_DIR}) qt5_add_dbus_adaptor( CONTENT_SERVICE_SKELETON ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml detail/service.h com::ubuntu::content::detail::Service) include_directories( ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content ${GSETTINGS_INCLUDE_DIRS} ${UPSTART_LAUNCH_INCLUDE_DIRS} ) add_executable( content-hub-service main.cpp registry.cpp ../debug.cpp ${CONTENT_SERVICE_SKELETON} ) qt5_use_modules(content-hub-service Core DBus Gui) target_link_libraries( content-hub-service content-hub ${GSETTINGS_LDFLAGS} ${UPSTART_LAUNCH_LDFLAGS} ) install( TARGETS content-hub-service RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) install( FILES com.ubuntu.content.dbus.Service.service DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services ) ########################### # GSettings ########################### add_schema ("com.ubuntu.content.hub.gschema.xml") add_executable( content-hub-peer-hook helper.cpp registry.cpp hook.cpp ) qt5_use_modules(content-hub-peer-hook Core Gui DBus) target_link_libraries( content-hub-peer-hook content-hub ${GSETTINGS_LDFLAGS} ${UPSTART_LAUNCH_LDFLAGS} ) install( TARGETS content-hub-peer-hook RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/content-hub" ) set_target_properties( content-hub-peer-hook PROPERTIES AUTOMOC TRUE ) set(CLICK_HOOK "${CMAKE_CURRENT_BINARY_DIR}/content-hub.hook" ) configure_file("content-hub.hook.in" "${CLICK_HOOK}" @ONLY ) install( FILES "${CLICK_HOOK}" DESTINATION "/usr/share/click/hooks" ) content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/hook.h0000644000015301777760000000237412323326002025306 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #ifndef HOOK_H #define HOOK_H #include #include #include #include "registry.h" namespace com { namespace ubuntu { namespace content { namespace detail { class Hook : public QObject { Q_OBJECT public: explicit Hook(QObject *parent = 0); Hook(com::ubuntu::content::detail::PeerRegistry *registry, QObject *parent = 0); public slots: bool return_error(QString err = ""); void run(); bool add_peer(QFileInfo); private: com::ubuntu::content::detail::PeerRegistry* registry; }; } } } } #endif // HOOK_H content-hub-0.0+14.04.20140415/src/com/ubuntu/content/service/registry.cpp0000644000015301777760000002177312323326002026555 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . * * Authored by: Ken VanDine */ #include "debug.h" #include "registry.h" #include "utils.cpp" #include Registry::Registry() : m_defaultSources(new QGSettings("com.ubuntu.content.hub.default", "/com/ubuntu/content/hub/peers/")), m_sources(new QGSettings("com.ubuntu.content.hub.source", "/com/ubuntu/content/hub/source/")), m_dests(new QGSettings("com.ubuntu.content.hub.destination", "/com/ubuntu/content/hub/destination/")), m_shares(new QGSettings("com.ubuntu.content.hub.share", "/com/ubuntu/content/hub/share/")) { /* ensure all default sources are registered as available sources */ QList types = known_types(); Q_FOREACH (cuc::Type type, types) { if (m_defaultSources->keys().contains(type.id())) { QVariant peer_v = m_defaultSources->get(type.id()); // If default isn't a StringList, attempt to reset if (peer_v.type() != QVariant::StringList) { TRACE() << Q_FUNC_INFO << "Default type for" << type.id() << "is incorrect, resetting"; m_defaultSources->reset(type.id()); // After reset, lets get a new QVariant peer_v = m_defaultSources->get(type.id()); } /* Only assume the default is correct if the type is a StringList * The reset above should have ensured it was reset, lets double * check anyway to prevent crashes */ if (peer_v.type() == QVariant::StringList) { QStringList as(peer_v.toStringList()); if (!as.isEmpty()) { std::string pkg = as[0].toStdString(); std::string app = as[1].toStdString(); std::string ver = as[2].toStdString(); cuc::Peer peer; if (app.empty() || ver.empty()) peer = QString::fromStdString(pkg); else peer = QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())); install_source_for_type(type, cuc::Peer{peer.id(), true}); } } } } } Registry::~Registry() {} cuc::Peer Registry::default_source_for_type(cuc::Type type) { TRACE() << Q_FUNC_INFO << type.id(); if (m_defaultSources->keys().contains(type.id())) { QVariant peer_v = m_defaultSources->get(type.id()); if (peer_v.type() != QVariant::StringList) return cuc::Peer(peer_v.toString()); QStringList as(peer_v.toStringList()); if (!as.isEmpty()) { std::string pkg = as[0].toStdString(); std::string app = as[1].toStdString(); std::string ver = as[2].toStdString(); if (app.empty() || ver.empty()) return cuc::Peer(QString::fromStdString(pkg)); return cuc::Peer(QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())), true); } } return cuc::Peer(); } void Registry::enumerate_known_peers(const std::function&for_each) { TRACE() << Q_FUNC_INFO; Q_FOREACH (QString type_id, m_sources->keys()) { TRACE() << Q_FUNC_INFO << type_id; Q_FOREACH (QString k, m_sources->get(type_id).toStringList()) { TRACE() << Q_FUNC_INFO << k; for_each(cuc::Peer{k}); } } Q_FOREACH (QString type_id, m_dests->keys()) { TRACE() << Q_FUNC_INFO << type_id; Q_FOREACH (QString k, m_dests->get(type_id).toStringList()) { TRACE() << Q_FUNC_INFO << k; for_each(cuc::Peer{k}); } } Q_FOREACH (QString type_id, m_shares->keys()) { TRACE() << Q_FUNC_INFO << type_id; Q_FOREACH (QString k, m_shares->get(type_id).toStringList()) { TRACE() << Q_FUNC_INFO << k; for_each(cuc::Peer{k}); } } } void Registry::enumerate_known_sources_for_type(cuc::Type type, const std::function&for_each) { TRACE() << Q_FUNC_INFO << type.id(); if (type == cuc::Type::unknown()) return; Q_FOREACH (QString k, m_sources->get(type.id()).toStringList()) { TRACE() << Q_FUNC_INFO << k; bool defaultPeer = false; QVariant peer_v = m_defaultSources->get(type.id()); if (peer_v.type() == QVariant::StringList) { QStringList as(peer_v.toStringList()); if (!as.isEmpty()) { std::string pkg = as[0].toStdString(); std::string app = as[1].toStdString(); std::string ver = as[2].toStdString(); if (app.empty() || ver.empty()) defaultPeer = QString::fromStdString(pkg) == k; else defaultPeer = QString::fromLocal8Bit(upstart_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())) == k; } } for_each(cuc::Peer{k, defaultPeer}); } } void Registry::enumerate_known_destinations_for_type(cuc::Type type, const std::function&for_each) { TRACE() << Q_FUNC_INFO << type.id(); if (type == cuc::Type::unknown()) return; Q_FOREACH (QString k, m_dests->get(type.id()).toStringList()) { TRACE() << Q_FUNC_INFO << k; for_each(cuc::Peer{k}); } } void Registry::enumerate_known_shares_for_type(cuc::Type type, const std::function&for_each) { TRACE() << Q_FUNC_INFO << type.id(); if (type == cuc::Type::unknown()) return; Q_FOREACH (QString k, m_shares->get(type.id()).toStringList()) { TRACE() << Q_FUNC_INFO << k; for_each(cuc::Peer{k}); } } bool Registry::install_default_source_for_type(cuc::Type type, cuc::Peer peer) { TRACE() << Q_FUNC_INFO << "type:" << type.id() << "peer:" << peer.id(); if (m_defaultSources->keys().contains(type.id())) { TRACE() << Q_FUNC_INFO << "Default peer for" << type.id() << "already installed."; return false; } this->install_source_for_type(type, peer); return m_defaultSources->trySet(type.id(), QVariant(peer.id())); } bool Registry::install_source_for_type(cuc::Type type, cuc::Peer peer) { TRACE() << Q_FUNC_INFO << "type:" << type.id() << "peer:" << peer.id(); QStringList l = m_sources->get(type.id()).toStringList(); if (not l.contains(peer.id())) { l.append(peer.id()); return m_sources->trySet(type.id(), QVariant(l)); } return false; } bool Registry::install_destination_for_type(cuc::Type type, cuc::Peer peer) { TRACE() << Q_FUNC_INFO << "type:" << type.id() << "peer:" << peer.id(); QStringList l = m_dests->get(type.id()).toStringList(); if (not l.contains(peer.id())) { l.append(peer.id()); return m_dests->trySet(type.id(), QVariant(l)); } return false; } bool Registry::install_share_for_type(cuc::Type type, cuc::Peer peer) { TRACE() << Q_FUNC_INFO << "type:" << type.id() << "peer:" << peer.id(); QStringList l = m_shares->get(type.id()).toStringList(); if (not l.contains(peer.id())) { l.append(peer.id()); return m_shares->trySet(type.id(), QVariant(l)); } return false; } bool Registry::remove_peer(cuc::Peer peer) { TRACE() << Q_FUNC_INFO << "peer:" << peer.id(); bool ret = false; Q_FOREACH (QString type_id, m_sources->keys()) { QStringList l = m_sources->get(type_id).toStringList(); if (l.contains(peer.id())) { l.removeAll(peer.id()); ret = m_sources->trySet(type_id, QVariant(l)); } } Q_FOREACH (QString type_id, m_dests->keys()) { QStringList l = m_dests->get(type_id).toStringList(); if (l.contains(peer.id())) { l.removeAll(peer.id()); ret = m_dests->trySet(type_id, QVariant(l)); } } Q_FOREACH (QString type_id, m_shares->keys()) { QStringList l = m_shares->get(type_id).toStringList(); if (l.contains(peer.id())) { l.removeAll(peer.id()); ret = m_shares->trySet(type_id, QVariant(l)); } } return ret; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/common.h0000644000015301777760000000213312323326002024167 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Ken VanDine */ #ifndef COMMON_H #define COMMON_H #include const QLatin1String HUB_SERVICE_NAME = QLatin1String("com.ubuntu.content.dbus.Service"); const QLatin1String HUB_SERVICE_PATH = QLatin1String("/"); const QLatin1String HANDLER_NAME_TEMPLATE = QLatin1String("com.ubuntu.content.handler.%1"); const QLatin1String HANDLER_BASE_PATH = QLatin1String("/com/ubuntu/content/handler"); #endif // COMMON_H content-hub-0.0+14.04.20140415/src/com/ubuntu/content/item.cpp0000644000015301777760000000257412323326002024201 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include namespace cuc = com::ubuntu::content; struct cuc::Item::Private { QUrl url; bool operator==(const Private& rhs) const { return url == rhs.url; } }; cuc::Item::Item(const QUrl& url, QObject* parent) : QObject(parent), d{new cuc::Item::Private{url}} { } cuc::Item::Item(const cuc::Item& rhs) : QObject(rhs.parent()), d(rhs.d) { } cuc::Item& cuc::Item::operator=(const cuc::Item& rhs) { d = rhs.d; return *this; } bool cuc::Item::operator==(const cuc::Item& rhs) const { if (d == rhs.d) return true; return *d == *rhs.d; } cuc::Item::~Item() { } const QUrl& cuc::Item::url() const { return d->url; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/hub.cpp0000644000015301777760000002004212323326002024007 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include "common.h" #include "debug.h" #include "ContentServiceInterface.h" #include "ContentHandlerInterface.h" #include "handleradaptor.h" #include "transfer_p.h" #include "utils.cpp" #include #include #include #include #include #include #include #include #include namespace cuc = com::ubuntu::content; struct cuc::Hub::Private { Private(QObject* parent) : service( new com::ubuntu::content::dbus::Service( HUB_SERVICE_NAME, HUB_SERVICE_PATH, QDBusConnection::sessionBus(), parent)) { } com::ubuntu::content::dbus::Service* service; }; cuc::Hub::Hub(QObject* parent) : QObject(parent), d{new cuc::Hub::Private{this}} { /* read environment variables */ QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); if (environment.contains(QLatin1String("CONTENT_HUB_LOGGING_LEVEL"))) { bool isOk; int value = environment.value( QLatin1String("CONTENT_HUB_LOGGING_LEVEL")).toInt(&isOk); if (isOk) setLoggingLevel(value); } } cuc::Hub::~Hub() { } cuc::Hub* cuc::Hub::Client::instance() { static cuc::Hub* hub = new cuc::Hub(nullptr); return hub; } void cuc::Hub::register_import_export_handler(cuc::ImportExportHandler* handler) { TRACE() << Q_FUNC_INFO; QString id = app_id(); if (id.isEmpty()) { qWarning() << "APP_ID isn't set, the handler can not be registered"; return; } auto c = QDBusConnection::sessionBus(); auto h = new cuc::detail::Handler(c, id, handler); new HandlerAdaptor(h); if (not c.registerObject(handler_path(id), h)) { qWarning() << Q_FUNC_INFO << "Failed to register object for:" << id; return; } d->service->RegisterImportExportHandler( id, QDBusObjectPath{handler_path(id)}); } const cuc::Store* cuc::Hub::store_for_scope_and_type(cuc::Scope scope, cuc::Type type) { static const std::map, cuc::Store*> lut = { {{cuc::system, cuc::Type::Known::pictures()}, new cuc::Store{"/content/Pictures", this}}, {{cuc::system, cuc::Type::Known::music()}, new cuc::Store{"/content/Music", this}}, {{cuc::system, cuc::Type::Known::documents()}, new cuc::Store{"/content/Documents", this}}, {{cuc::user, cuc::Type::Known::pictures()}, new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::PicturesLocation), this}}, {{cuc::user, cuc::Type::Known::music()}, new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::MusicLocation), this}}, {{cuc::user, cuc::Type::Known::documents()}, new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), this}}, {{cuc::app, cuc::Type::Known::pictures()}, new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Pictures", this}}, {{cuc::app, cuc::Type::Known::music()}, new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Music", this}}, {{cuc::app, cuc::Type::Known::documents()}, new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Documents", this}}, }; auto it = lut.find(std::make_pair(scope, type)); if (it == lut.end()) return nullptr; return it->second; } cuc::Peer cuc::Hub::default_source_for_type(cuc::Type t) { TRACE() << Q_FUNC_INFO; auto reply = d->service->DefaultSourceForType(t.id()); reply.waitForFinished(); if (reply.isError()) return cuc::Peer::unknown(); auto peer = reply.value(); return qdbus_cast(peer.variant()); } QVector cuc::Hub::known_sources_for_type(cuc::Type t) { QVector result; auto reply = d->service->KnownSourcesForType(t.id()); reply.waitForFinished(); if (reply.isError()) return result; auto peers = reply.value(); Q_FOREACH(const QVariant& p, peers) { result << qdbus_cast(p); } return result; } QVector cuc::Hub::known_destinations_for_type(cuc::Type t) { QVector result; auto reply = d->service->KnownDestinationsForType(t.id()); reply.waitForFinished(); if (reply.isError()) return result; auto peers = reply.value(); Q_FOREACH(const QVariant& p, peers) { result << qdbus_cast(p); } return result; } QVector cuc::Hub::known_shares_for_type(cuc::Type t) { QVector result; auto reply = d->service->KnownSharesForType(t.id()); reply.waitForFinished(); if (reply.isError()) return result; auto peers = reply.value(); Q_FOREACH(const QVariant& p, peers) { result << qdbus_cast(p); } return result; } cuc::Transfer* cuc::Hub::create_import_from_peer(cuc::Peer peer) { /* This needs to be replaced with a better way to get the APP_ID */ QString id = app_id(); auto reply = d->service->CreateImportFromPeer(peer.id(), id); reply.waitForFinished(); if (reply.isError()) return nullptr; cuc::Transfer *transfer = cuc::Transfer::Private::make_transfer(reply.value(), this); const cuc::Store *store = new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/HubIncoming/" + QString::number(transfer->id()), this}; transfer->setStore(store); return transfer; } cuc::Transfer* cuc::Hub::create_export_to_peer(cuc::Peer peer) { /* This needs to be replaced with a better way to get the APP_ID */ QString id = app_id(); auto reply = d->service->CreateExportToPeer(peer.id(), id); reply.waitForFinished(); if (reply.isError()) return nullptr; cuc::Transfer *transfer = cuc::Transfer::Private::make_transfer(reply.value(), this); QString peerName = peer.id().split("_")[0]; TRACE() << Q_FUNC_INFO << "peerName: " << peerName; const cuc::Store *store = new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/" + peerName + "/HubIncoming/" + QString::number(transfer->id()), this}; TRACE() << Q_FUNC_INFO << "STORE:" << store->uri(); transfer->setStore(store); transfer->start(); return transfer; } cuc::Transfer* cuc::Hub::create_share_to_peer(cuc::Peer peer) { /* This needs to be replaced with a better way to get the APP_ID */ QString id = app_id(); auto reply = d->service->CreateShareToPeer(peer.id(), id); reply.waitForFinished(); if (reply.isError()) return nullptr; cuc::Transfer *transfer = cuc::Transfer::Private::make_transfer(reply.value(), this); QString peerName = peer.id().split("_")[0]; TRACE() << Q_FUNC_INFO << "peerName: " << peerName; const cuc::Store *store = new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/" + peerName + "/HubIncoming/" + QString::number(transfer->id()), this}; TRACE() << Q_FUNC_INFO << "STORE:" << store->uri(); transfer->setStore(store); transfer->start(); return transfer; } void cuc::Hub::quit() { d->service->Quit(); } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/utils.cpp0000644000015301777760000001134212323326002024374 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Ken VanDine */ #include #include #include #include #include #include #include #include #include #include "common.h" #include "debug.h" #include "com/ubuntu/content/type.h" #include namespace cuc = com::ubuntu::content; namespace { QList known_types() { QList types; types << cuc::Type::Known::pictures(); types << cuc::Type::Known::music(); types << cuc::Type::Known::documents(); types << cuc::Type::Known::contacts(); return types; } /* sanitize the dbus names */ QString sanitize_id(const QString& appId) { TRACE() << Q_FUNC_INFO; return QString(nih_dbus_path(NULL, "", appId.toLocal8Bit().data(), NULL)).remove(0, 1); } /* define a bus_name based on our namespace and the app_id */ QString handler_address(QString app_id) { return QString(HANDLER_NAME_TEMPLATE).arg(sanitize_id(app_id)); } QString handler_path(QString app_id) { return nih_dbus_path(NULL, HANDLER_BASE_PATH.data(), app_id.toLocal8Bit().data(), NULL); } QString app_id() { /* FIXME: rely on APP_ID from env for now, * but we'll use this function as a place to * later use the application manager */ return QString(qgetenv("APP_ID")); } QString aa_profile(QString uniqueConnectionId) { TRACE() << Q_FUNC_INFO << uniqueConnectionId; QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetConnectionAppArmorSecurityContext"); QString aaProfile; QVariantList args; args << uniqueConnectionId; msg.setArguments(args); QDBusMessage reply = QDBusConnection::sessionBus().call(msg, QDBus::Block); if (reply.type() == QDBusMessage::ReplyMessage) { aaProfile = reply.arguments().value(0, QString()).toString(); TRACE() << "AppArmor Profile:" << aaProfile; } else { qWarning() << "Error getting app ID:" << reply.errorName() << reply.errorMessage(); } if (aaProfile.toStdString() == QString("unconfined").toStdString()) { return QString(""); } return aaProfile; } bool is_persistent(QString store) { TRACE() << Q_FUNC_INFO << store; QRegExp rx("*.cache/*/HubIncoming/*"); rx.setPatternSyntax(QRegExp::Wildcard); rx.setCaseSensitivity(Qt::CaseSensitive); return not rx.exactMatch(store); } QString copy_to_store(const QString& src, const QString& store) { TRACE() << Q_FUNC_INFO; QUrl srcUrl(src); if (not srcUrl.isLocalFile()) return srcUrl.url(); QFileInfo fi(srcUrl.toLocalFile()); QDir st(store); if (not st.exists()) st.mkpath(st.absolutePath()); QString destFilePath = store + QDir::separator() + fi.fileName(); TRACE() << Q_FUNC_INFO << destFilePath; bool copy_failed = true; if (not is_persistent(store)) { if (link( fi.absoluteFilePath().toStdString().c_str(), destFilePath.toStdString().c_str() ) < 0) { qWarning() << "Can't create hard link to Store:" << store; } else copy_failed = false; } if (copy_failed) { if (not QFile::copy(fi.filePath(), destFilePath)) qWarning() << "Failed to copy to Store:" << store; } return QUrl::fromLocalFile(destFilePath).toString(); } bool purge_store_cache(QString store) { TRACE() << Q_FUNC_INFO << "Store:" << store; if (is_persistent(store)) { TRACE() << Q_FUNC_INFO << store << "is persistent"; return false; } QDir st(store); if (st.exists()) { TRACE() << Q_FUNC_INFO << store << "isn't persistent, purging"; return st.removeRecursively(); } return false; } } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/store.cpp0000644000015301777760000000227312323326002024373 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include namespace cuc = com::ubuntu::content; struct cuc::Store::Private { QString uri; }; cuc::Store::Store(const QString& uri, QObject* parent) : QObject(parent), d(new cuc::Store::Private{uri}) { } cuc::Store::Store(const cuc::Store& rhs) : QObject(rhs.parent()), d(rhs.d) { } cuc::Store& cuc::Store::operator=(const cuc::Store& rhs) { d = rhs.d; return *this; } cuc::Store::~Store() { } const QString& cuc::Store::uri() const { return d->uri; } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/transfer.cpp0000644000015301777760000000466712323326002025074 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include #include "transfer_p.h" #include "utils.cpp" namespace cuc = com::ubuntu::content; cuc::Transfer::Transfer(const QSharedPointer& d, QObject* parent) : QObject(parent), d(d) { QObject::connect(d->remote_transfer, SIGNAL (StateChanged(int)), this, SIGNAL (stateChanged())); QObject::connect(d->remote_transfer, SIGNAL (StoreChanged(QString)), this, SIGNAL (storeChanged())); QObject::connect(d->remote_transfer, SIGNAL (SelectionTypeChanged(int)), this, SIGNAL (selectionTypeChanged())); } cuc::Transfer::~Transfer() { TRACE() << Q_FUNC_INFO; purge_store_cache(d->store().uri()); } int cuc::Transfer::id() const { return d->id(); } cuc::Transfer::State cuc::Transfer::state() const { return d->state(); } bool cuc::Transfer::start() { return d->start(); } bool cuc::Transfer::abort() { return d->abort(); } bool cuc::Transfer::charge(const QVector& items) { return d->charge(items); } QVector cuc::Transfer::collect() { return d->collect(); } bool cuc::Transfer::finalize() { return d->finalize(); } cuc::Store cuc::Transfer::store() const { return d->store(); } bool cuc::Transfer::setStore(const cuc::Store* store) { return d->setStore(store); } cuc::Transfer::SelectionType cuc::Transfer::selectionType() const { return d->selection_type(); } bool cuc::Transfer::setSelectionType(const cuc::Transfer::SelectionType& type) { return d->setSelectionType(type); } cuc::Transfer::Direction cuc::Transfer::direction() const { return d->direction(); } content-hub-0.0+14.04.20140415/src/com/ubuntu/content/CMakeLists.txt0000644000015301777760000000662412323326002025277 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss add_subdirectory(service) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include ${GLIB_INCLUDE_DIRS} ${GIO_INCLUDE_DIRS} ${NIH_INCLUDE_DIRS} ${NIH_DBUS_INCLUDE_DIRS} ${UPSTART_LAUNCH_INCLUDE_DIRS} ) qt5_add_dbus_interface( CONTENT_SERVICE_STUB ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Service.xml ContentServiceInterface) qt5_add_dbus_adaptor( CONTENT_SERVICE_SKELETON ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Service.xml detail/service.h com::ubuntu::content::detail::Service) qt5_add_dbus_interface( CONTENT_TRANSFER_STUB ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Transfer.xml ContentTransferInterface) qt5_add_dbus_adaptor( CONTENT_TRANSFER_SKELETON ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Transfer.xml detail/transfer.h com::ubuntu::content::detail::Transfer) qt5_add_dbus_interface( CONTENT_HANDLER_STUB ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Handler.xml ContentHandlerInterface) qt5_add_dbus_adaptor( CONTENT_HANDLER_SKELETON ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Handler.xml detail/handler.h com::ubuntu::content::detail::Handler) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/hub.h) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/import_export_handler.h) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/item.h) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/peer.h) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/store.h) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/transfer.h) qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/type.h) add_library( content-hub SHARED hub.cpp import_export_handler.cpp item.cpp peer.cpp store.cpp transfer.cpp type.cpp utils.cpp debug.cpp detail/app_manager.cpp detail/service.cpp detail/transfer.cpp detail/handler.cpp ${CONTENT_HUB_MOCS} ${CONTENT_SERVICE_STUB} ${CONTENT_SERVICE_SKELETON} ${CONTENT_TRANSFER_STUB} ${CONTENT_TRANSFER_SKELETON} ${CONTENT_HANDLER_STUB} ${CONTENT_HANDLER_SKELETON} ) set_target_properties( content-hub PROPERTIES VERSION ${CONTENT_HUB_VERSION_MAJOR}.${CONTENT_HUB_VERSION_MINOR}.${CONTENT_HUB_VERSION_PATCH} SOVERSION ${CONTENT_HUB_VERSION_MAJOR} AUTOMOC TRUE ) qt5_use_modules(content-hub Core DBus Gui) target_link_libraries(content-hub ${UPSTART_LAUNCH_LDFLAGS} ${NIH_LIBRARIES} ${NIH_DBUS_LIBRARIES} ${GIO_LIBRARIES} ) install( TARGETS content-hub LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) content-hub-0.0+14.04.20140415/src/com/ubuntu/content/peer.cpp0000644000015301777760000000770612323326002024200 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #include #include #include #include "debug.h" namespace cuc = com::ubuntu::content; struct cuc::Peer::Private { Private (QString id, bool isDefaultPeer) : id(id), isDefaultPeer(isDefaultPeer) { TRACE() << Q_FUNC_INFO << id; if (name.isEmpty()) { QString desktop_id(id + ".desktop"); GDesktopAppInfo* app = g_desktop_app_info_new(desktop_id.toLocal8Bit().data()); if (G_IS_APP_INFO(app)) { name = QString::fromLatin1(g_app_info_get_display_name(G_APP_INFO(app))); GIcon* ic = g_app_info_get_icon(G_APP_INFO(app)); if (G_IS_ICON(ic)) { iconName = QString::fromUtf8(g_icon_to_string(ic)); if (QFile::exists(iconName)) { QFile iconFile(iconName); if(iconFile.open(QIODevice::ReadOnly)) { iconData = iconFile.readAll(); iconFile.close(); } } } g_object_unref(app); } } } QString id; QString name; QByteArray iconData; QString iconName; bool isDefaultPeer; }; const cuc::Peer& cuc::Peer::unknown() { static cuc::Peer peer; return peer; } cuc::Peer::Peer(const QString& id, bool isDefaultPeer, QObject* parent) : QObject(parent), d(new cuc::Peer::Private{id, isDefaultPeer}) { TRACE() << Q_FUNC_INFO; } cuc::Peer::Peer(const cuc::Peer& rhs) : QObject(rhs.parent()), d(rhs.d) { } cuc::Peer::~Peer() { } cuc::Peer& cuc::Peer::operator=(const cuc::Peer& rhs) { d = rhs.d; return *this; } bool cuc::Peer::operator==(const cuc::Peer& rhs) const { if (d == rhs.d) return true; return d->id == rhs.d->id; } const QString& cuc::Peer::id() const { return d->id; } QString cuc::Peer::name() const { return d->name; } void cuc::Peer::setName(const QString& name) { if (name != d->name) d->name = name; } QByteArray cuc::Peer::iconData() const { return d->iconData; } void cuc::Peer::setIconData(const QByteArray& iconData) { if (iconData != d->iconData) d->iconData = iconData; } QString cuc::Peer::iconName() const { return d->iconName; } void cuc::Peer::setIconName(const QString& iconName) { if (iconName != d->iconName) d->iconName = iconName; } bool cuc::Peer::isDefaultPeer() const { return d->isDefaultPeer; } QDBusArgument &operator<<(QDBusArgument &argument, const cuc::Peer& peer) { argument.beginStructure(); argument << peer.id() << peer.name() << peer.iconData() << peer.iconName() << peer.isDefaultPeer(); argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, cuc::Peer &peer) { TRACE() << Q_FUNC_INFO; QString id; QString name; QByteArray ic; QString iconName; bool isDefaultPeer; argument.beginStructure(); argument >> id >> name >> ic >> iconName >> isDefaultPeer; argument.endStructure(); peer = cuc::Peer{id, isDefaultPeer}; peer.setName(name); peer.setIconData(ic); peer.setIconName(iconName); return argument; } content-hub-0.0+14.04.20140415/src/com/ubuntu/CMakeLists.txt0000644000015301777760000000126212323326002023616 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss add_subdirectory(content)content-hub-0.0+14.04.20140415/src/com/CMakeLists.txt0000644000015301777760000000126112323326002022273 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . # # Authored by: Thomas Voss add_subdirectory(ubuntu)content-hub-0.0+14.04.20140415/include/0000755000015301777760000000000012323326474017626 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/include/com/0000755000015301777760000000000012323326474020404 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/include/com/ubuntu/0000755000015301777760000000000012323326474021726 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/include/com/ubuntu/content/0000755000015301777760000000000012323326474023400 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/include/com/ubuntu/content/item.h0000644000015301777760000000243612323326002024477 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_ITEM_H_ #define COM_UBUNTU_CONTENT_ITEM_H_ #include #include #include namespace com { namespace ubuntu { namespace content { class Item : public QObject { Q_OBJECT Q_PROPERTY(QUrl url READ url()) public: Item(const QUrl& = QUrl(), QObject* = nullptr); Item(const Item&); virtual ~Item(); Item& operator=(const Item&); bool operator==(const Item&) const; Q_INVOKABLE const QUrl& url() const; private: struct Private; QSharedPointer d; }; } } } #endif // COM_UBUNTU_CONTENT_ITEM_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/type.h0000644000015301777760000000330612323326002024517 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_TYPE_H_ #define COM_UBUNTU_CONTENT_TYPE_H_ #include #include namespace com { namespace ubuntu { namespace content { namespace detail { class Service; class Hook; } class Type : public QObject { Q_OBJECT Q_PROPERTY(QString id READ id()) public: static const Type& unknown(); struct Known { static const Type& documents(); static const Type& pictures(); static const Type& music(); static const Type& contacts(); }; virtual ~Type(); Type(const Type&); Type& operator=(const Type&); bool operator==(const Type&) const; bool operator<(const Type&) const; Q_INVOKABLE virtual const QString& id() const; protected: friend struct Known; friend class detail::Service; friend class detail::Hook; explicit Type(const QString&, QObject* = nullptr); private: struct Private; QSharedPointer d; }; } } } #endif // COM_UBUNTU_CONTENT_TYPE_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/transfer.h0000644000015301777760000000572112323326002025365 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_TRANSFER_H_ #define COM_UBUNTU_CONTENT_TRANSFER_H_ #include #include #include #include #include namespace com { namespace ubuntu { namespace content { namespace detail { class Handler; } } } } namespace com { namespace ubuntu { namespace content { class Item; class Transfer : public QObject { Q_OBJECT Q_ENUMS(State) Q_ENUMS(SelectionType) Q_ENUMS(Direction) Q_PROPERTY(int id READ id) Q_PROPERTY(State state READ state NOTIFY stateChanged) Q_PROPERTY(QVector items READ collect WRITE charge) Q_PROPERTY(Store store READ store NOTIFY storeChanged) Q_PROPERTY(SelectionType selectionType READ selectionType WRITE setSelectionType NOTIFY selectionTypeChanged) Q_PROPERTY(Direction direction READ direction) public: enum State { created, initiated, in_progress, charged, collected, aborted, finalized }; enum SelectionType { single, multiple }; enum Direction { Import, Export, Share }; Transfer(const Transfer&) = delete; virtual ~Transfer(); Transfer& operator=(const Transfer&) = delete; Q_INVOKABLE virtual int id() const; Q_INVOKABLE virtual State state() const; Q_INVOKABLE virtual SelectionType selectionType() const; Q_INVOKABLE virtual Direction direction() const; Q_INVOKABLE virtual bool start(); Q_INVOKABLE virtual bool abort(); Q_INVOKABLE virtual bool finalize(); Q_INVOKABLE virtual bool charge(const QVector& items); Q_INVOKABLE virtual QVector collect(); Q_INVOKABLE virtual Store store() const; Q_INVOKABLE virtual bool setStore(const Store*); Q_INVOKABLE virtual bool setSelectionType(const SelectionType&); Q_SIGNAL void stateChanged(); Q_SIGNAL void storeChanged(); Q_SIGNAL void selectionTypeChanged(); private: struct Private; friend struct Private; friend class Hub; friend class com::ubuntu::content::detail::Handler; QSharedPointer d; Transfer(const QSharedPointer&, QObject* parent = nullptr); }; } } } #endif // COM_UBUNTU_CONTENT_TRANSFER_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/store.h0000644000015301777760000000241112323326002024666 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_STORE_H_ #define COM_UBUNTU_CONTENT_STORE_H_ #include #include namespace com { namespace ubuntu { namespace content { class Store : public QObject { Q_OBJECT public: Q_PROPERTY(QString uri READ uri) Store(const QString& uri, QObject* parent = nullptr); Store(const Store&); virtual ~Store(); Store& operator=(const Store&); Q_INVOKABLE virtual const QString& uri() const; protected: struct Private; QSharedPointer d; }; } } } #endif // COM_UBUNTU_CONTENT_STORE_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/scope.h0000644000015301777760000000166212323326002024652 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_SCOPE_H_ #define COM_UBUNTU_CONTENT_SCOPE_H_ #include namespace com { namespace ubuntu { namespace content { enum Scope { system, user, app }; } } } #endif // COM_UBUNTU_CONTENT_SCOPE_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/hub.h0000644000015301777760000000411212323326002024310 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_HUB_H_ #define COM_UBUNTU_CONTENT_HUB_H_ #include #include #include #include #include namespace com { namespace ubuntu { namespace content { class ImportExportHandler; class Store; class Transfer; class Hub : public QObject { Q_OBJECT public: struct Client { static Hub* instance(); }; Hub(const Hub&) = delete; virtual ~Hub(); Hub& operator=(const Hub&) = delete; Q_INVOKABLE virtual void register_import_export_handler(ImportExportHandler* handler); Q_INVOKABLE virtual const Store* store_for_scope_and_type(Scope scope, Type type); Q_INVOKABLE virtual Peer default_source_for_type(Type type); Q_INVOKABLE virtual QVector known_sources_for_type(Type type); Q_INVOKABLE virtual QVector known_destinations_for_type(Type type); Q_INVOKABLE virtual QVector known_shares_for_type(Type type); Q_INVOKABLE virtual Transfer* create_import_from_peer(Peer peer); Q_INVOKABLE virtual Transfer* create_export_to_peer(Peer peer); Q_INVOKABLE virtual Transfer* create_share_to_peer(Peer peer); Q_INVOKABLE virtual void quit(); protected: Hub(QObject* = nullptr); private: struct Private; QScopedPointer d; }; } } } #endif // COM_UBUNTU_CONTENT_HUB_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/peer.h0000644000015301777760000000431512323326002024472 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_PEER_H_ #define COM_UBUNTU_CONTENT_PEER_H_ #include #include #include #include namespace com { namespace ubuntu { namespace content { class Peer : public QObject { Q_OBJECT Q_PROPERTY(QString id READ id) Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString iconName READ iconName WRITE setIconName) Q_PROPERTY(bool isDefaultPeer READ isDefaultPeer) public: static const Peer& unknown(); Peer(const QString& id = QString(), bool isDefaultPeer = false, QObject* parent = nullptr); Peer(const Peer& rhs); virtual ~Peer(); Peer& operator=(const Peer& rhs); bool operator==(const Peer& rhs) const; Q_INVOKABLE virtual const QString& id() const; Q_INVOKABLE virtual QString name() const; Q_INVOKABLE void setName(const QString&); Q_INVOKABLE virtual QByteArray iconData() const; Q_INVOKABLE void setIconData(const QByteArray&); Q_INVOKABLE virtual QString iconName() const; Q_INVOKABLE void setIconName(const QString&); Q_INVOKABLE virtual bool isDefaultPeer() const; private: struct Private; QSharedPointer d; }; } } } Q_DECL_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const com::ubuntu::content::Peer &peer); Q_DECL_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, com::ubuntu::content::Peer &peer); Q_DECLARE_METATYPE(com::ubuntu::content::Peer) #endif // COM_UBUNTU_CONTENT_PEER_H_ content-hub-0.0+14.04.20140415/include/com/ubuntu/content/import_export_handler.h0000644000015301777760000000266512323326002030155 0ustar pbusernogroup00000000000000/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 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 . * * Authored by: Thomas Voß */ #ifndef COM_UBUNTU_CONTENT_IMPORT_EXPORT_HANDLER_H_ #define COM_UBUNTU_CONTENT_IMPORT_EXPORT_HANDLER_H_ #include namespace com { namespace ubuntu { namespace content { class Transfer; class ImportExportHandler : public QObject { Q_OBJECT public: ImportExportHandler(const ImportExportHandler&) = delete; virtual ~ImportExportHandler() = default; ImportExportHandler& operator=(const ImportExportHandler&) = delete; Q_INVOKABLE virtual void handle_import(Transfer*) = 0; Q_INVOKABLE virtual void handle_export(Transfer*) = 0; Q_INVOKABLE virtual void handle_share(Transfer*) = 0; protected: ImportExportHandler(QObject* parent = nullptr); }; } } } #endif // COM_UBUNTU_CONTENT_IMPORT_EXPORT_HANDLER_H_ content-hub-0.0+14.04.20140415/contenthub.qmlproject0000644000015301777760000000052512323326002022443 0ustar pbusernogroup00000000000000/* File generated by Qt Creator, version 2.5.2 */ import QmlProject 1.1 Project { mainFile: "examples/export-qml/export.qml" /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { directory: ["examples/export-qml", "examples/import-qml", "import/Ubuntu/Content"] } } content-hub-0.0+14.04.20140415/import/0000755000015301777760000000000012323326474017515 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/import/Ubuntu/0000755000015301777760000000000012323326474020777 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/import/Ubuntu/Content/0000755000015301777760000000000012323326474022411 5ustar pbusernogroup00000000000000content-hub-0.0+14.04.20140415/import/Ubuntu/Content/ResponsiveGridView.qml0000644000015301777760000000704512323326017026721 0ustar pbusernogroup00000000000000/* * 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 as published by * the Free Software Foundation; version 3. * * This program 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 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 . */ import QtQuick 2.0 import Ubuntu.Components 0.1 /* Essentially a GridView where you can specify the maximum number of columns it can have. */ Item { property int minimumHorizontalSpacing: units.gu(0.5) // property int minimumNumberOfColumns: 2 // FIXME: not implemented property int maximumNumberOfColumns: 6 readonly property int columns: gridView.columns property alias verticalSpacing: gridView.verticalSpacing readonly property alias margins: gridView.margin property int delegateWidth property int delegateHeight property alias model: gridView.model property alias delegate: gridView.delegate readonly property int cellWidth: gridView.cellWidth readonly property int cellHeight: gridView.cellHeight property alias interactive: gridView.interactive readonly property alias flicking: gridView.flicking readonly property alias moving: gridView.moving readonly property alias pressDelay: gridView.pressDelay property alias delegateCreationBegin: gridView.delegateCreationBegin property alias delegateCreationEnd: gridView.delegateCreationEnd property alias highlightIndex: gridView.highlightIndex readonly property alias currentItem: gridView.currentItem function contentHeightForRows(rows) { return rows * cellHeight + verticalSpacing } GridView { id: gridView objectName: "responsiveGridViewGrid" anchors { fill: parent leftMargin: margin/2 rightMargin: margin/2 topMargin: verticalSpacing } onModelChanged: { clip = parent.height != contentHeightForRows(Math.ceil(model.count / columns)) } function pixelToGU(value) { return Math.floor(value / units.gu(1)); } function spacingForColumns(columns) { // spacing between columns as an integer number of GU, the remainder goes in the margins var spacingGU = pixelToGU(allocatableHorizontalSpace / columns); return units.gu(spacingGU); } function columnsForSpacing(spacing) { // minimum margin is half of the spacing return Math.max(1, Math.floor(parent.width / (delegateWidth + spacing))); } property real allocatableHorizontalSpace: parent.width - columns * delegateWidth property int columns: Math.min(columnsForSpacing(minimumHorizontalSpacing), maximumNumberOfColumns) property real horizontalSpacing: spacingForColumns(columns) property real verticalSpacing: horizontalSpacing property int margin: allocatableHorizontalSpace - columns * horizontalSpacing property int highlightIndex: -1 cellWidth: delegateWidth + horizontalSpacing cellHeight: delegateHeight + verticalSpacing onHighlightIndexChanged: { if (highlightIndex != -1) { currentIndex = highlightIndex } } } } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentpeer.h0000644000015301777760000000540712323326002025101 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTPEER_H_ #define COM_UBUNTU_CONTENTPEER_H_ #include "contenthandler.h" #include "contenttransfer.h" #include "contenttype.h" #include #include #include #include #include class ContentPeer : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString appId READ appId WRITE setAppId NOTIFY appIdChanged) Q_PROPERTY(ContentHandler::Handler handler READ handler WRITE setHandler NOTIFY handlerChanged) Q_PROPERTY(ContentType::Type contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged) Q_PROPERTY(ContentTransfer::SelectionType selectionType READ selectionType WRITE setSelectionType NOTIFY selectionTypeChanged) Q_PROPERTY(QImage icon READ icon) Q_PROPERTY(bool isDefaultPeer READ isDefaultPeer) public: ContentPeer(QObject *parent = nullptr); ContentPeer(ContentType::Type type, QObject *parent); Q_INVOKABLE ContentTransfer* request(); Q_INVOKABLE ContentTransfer* request(ContentStore *store); QString name(); const QString &appId() const; void setAppId(const QString&); QImage &icon(); const com::ubuntu::content::Peer &peer() const; void setPeer(const com::ubuntu::content::Peer &peer, bool explicitPeer = true); ContentHandler::Handler handler(); void setHandler(ContentHandler::Handler handler); ContentType::Type contentType(); void setContentType(ContentType::Type contentType); ContentTransfer::SelectionType selectionType(); void setSelectionType(ContentTransfer::SelectionType selectionType); bool isDefaultPeer(); Q_SIGNALS: void nameChanged(); void appIdChanged(); void handlerChanged(); void contentTypeChanged(); void selectionTypeChanged(); private: void init(); com::ubuntu::content::Hub *m_hub; com::ubuntu::content::Peer m_peer; ContentHandler::Handler m_handler; ContentType::Type m_contentType; ContentTransfer::SelectionType m_selectionType; bool m_explicit_peer; QImage m_icon; }; #endif // COM_UBUNTU_CONTENTPEER_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenticonprovider.cpp0000644000015301777760000000326412323326002027203 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contenticonprovider.h" ContentIconProvider::ContentIconProvider() : QQuickImageProvider(QQuickImageProvider::Image) { TRACE() << Q_FUNC_INFO; appIdImageMap = new QMap(); } ContentIconProvider *ContentIconProvider::instance() { static ContentIconProvider *contentIconProvider = new ContentIconProvider(); return contentIconProvider; } /*! * \brief void ContentIconProvider::addImage * * Add an app's icon to the provider */ void ContentIconProvider::addImage(QString appId, QImage image) { TRACE() << Q_FUNC_INFO; appIdImageMap->insert(appId, image); } /*! * \brief QImage ContentIconProvider::requestImage * * Returns the QImage for a given appId at the requested size */ QImage ContentIconProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { Q_UNUSED(requestedSize) TRACE() << Q_FUNC_INFO; QImage image = appIdImageMap->value(id); if(size) { *size = image.size(); } return image; } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentpeer.cpp0000644000015301777760000001360112323326002025427 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contenthandler.h" #include "contenthub.h" #include "contenticonprovider.h" #include "contentpeer.h" #include "contenttype.h" #include #include /*! * \qmltype ContentPeer * \instantiates ContentPeer * \inqmlmodule Ubuntu.Content * \brief An application that can export or import a ContentType * * A ContentPeer is an application that is registered in the ContentHub as * a source or destination of a ContentType * * See documentation for ContentHub */ namespace cuc = com::ubuntu::content; ContentPeer::ContentPeer(QObject *parent) : QObject(parent), m_peer(0), m_handler(ContentHandler::Source), m_contentType(ContentType::Unknown), m_selectionType(ContentTransfer::Single), m_explicit_peer(false) { TRACE() << Q_FUNC_INFO; m_hub = cuc::Hub::Client::instance(); } /*! * \qmlproperty string ContentPeer::name * * Returns user friendly name of the peer. */ QString ContentPeer::name() { TRACE() << Q_FUNC_INFO; return m_peer.name(); } /*! * \qmlproperty string ContentPeer::appId * When set, this property allows for a specific application to be used as a peer. */ const QString &ContentPeer::appId() const { TRACE() << Q_FUNC_INFO; return m_peer.id(); } /*! * \brief ContentPeer::setAppId * \internal * Sets the Application id */ void ContentPeer::setAppId(const QString& appId) { TRACE() << Q_FUNC_INFO << appId; this->setPeer(cuc::Peer{appId}); } QImage &ContentPeer::icon() { TRACE() << Q_FUNC_INFO; return m_icon; } /*! * \brief ContentPeer::peer * \internal */ const com::ubuntu::content::Peer &ContentPeer::peer() const { return m_peer; } /*! * \brief ContentPeer::setPeer * \internal */ void ContentPeer::setPeer(const cuc::Peer &peer, bool explicitPeer) { TRACE() << Q_FUNC_INFO; m_peer = peer; m_explicit_peer = explicitPeer; if (peer.iconData().isEmpty()) { if (QIcon::hasThemeIcon(peer.iconName().toUtf8())) m_icon = QIcon::fromTheme(peer.iconName().toUtf8()).pixmap(256).toImage(); } else m_icon.loadFromData(peer.iconData()); ContentIconProvider *iconProvider = ContentIconProvider::instance(); iconProvider->addImage(appId(), m_icon); Q_EMIT nameChanged(); Q_EMIT appIdChanged(); } /*! * \qmlproperty ContentHandler ContentPeer::handler * Specifies which ContentHandler this peer should support (e.g. Source, Destination, Share). */ ContentHandler::Handler ContentPeer::handler() { TRACE() << Q_FUNC_INFO; return m_handler; } /*! * \brief ContentPeer::setHandler * \internal */ void ContentPeer::setHandler(ContentHandler::Handler handler) { TRACE() << Q_FUNC_INFO; m_handler = handler; Q_EMIT handlerChanged(); } /*! * \qmlproperty ContentType ContentPeer::contentType * Specifies the ContentType this peer should support. */ ContentType::Type ContentPeer::contentType() { TRACE() << Q_FUNC_INFO; return m_contentType; } /*! * \brief ContentPeer::setContentType * \internal */ void ContentPeer::setContentType(ContentType::Type contentType) { TRACE() << Q_FUNC_INFO; m_contentType = contentType; if(!m_explicit_peer) { const cuc::Type &hubType = ContentType::contentType2HubType(m_contentType); setPeer(m_hub->default_source_for_type(hubType), false); } Q_EMIT contentTypeChanged(); } /*! * \qmlproperty ContentTransfer.SelectionType ContentPeer::selectionType * Specifies whether this peer is allowed to return multiple items. */ ContentTransfer::SelectionType ContentPeer::selectionType() { TRACE() << Q_FUNC_INFO; return m_selectionType; } /*! * \brief ContentPeer::setSelectionType * \internal */ void ContentPeer::setSelectionType(ContentTransfer::SelectionType selectionType) { TRACE() << Q_FUNC_INFO; m_selectionType = selectionType; Q_EMIT selectionTypeChanged(); } /*! * \brief ContentPeer::isDefaultPeer * \internal */ bool ContentPeer::isDefaultPeer() { TRACE() << Q_FUNC_INFO; return m_peer.isDefaultPeer(); } /*! * \qmlmethod ContentPeer::request() * * \brief Request an active transfer from this ContentPeer. */ ContentTransfer *ContentPeer::request() { TRACE() << Q_FUNC_INFO; return request(nullptr); } /*! * \qmlmethod ContentPeer::request(ContentStore) * * \brief Request to an active transfer from this ContentPeer and use * a ContentStore for permanent storage. */ ContentTransfer *ContentPeer::request(ContentStore *store) { TRACE() << Q_FUNC_INFO; ContentHub *contentHub = ContentHub::instance(); ContentTransfer *qmlTransfer = NULL; if(m_handler == ContentHandler::Source) { qmlTransfer = contentHub->importContent(m_peer); } else if (m_handler == ContentHandler::Destination) { qmlTransfer = contentHub->exportContent(m_peer); } else if (m_handler == ContentHandler::Share) { qmlTransfer = contentHub->shareContent(m_peer); } qmlTransfer->setSelectionType(m_selectionType); if(store) { store->updateStore(m_contentType); qmlTransfer->setStore(store); } /* We only need to start it for import requests */ if (m_handler == ContentHandler::Source) qmlTransfer->start(); return qmlTransfer; } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenthubplugin.h0000644000015301777760000000215412323326002026137 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENT_PLUGIN_H_ #define COM_UBUNTU_CONTENT_PLUGIN_H_ #include #include class ContentHub; class ContentHubPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: void initializeEngine(QQmlEngine * engine, const char * uri); void registerTypes(const char *uri); private: ContentHub *m_contentHub; }; #endif // COM_UBUNTU_CONTENT_PLUGIN_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/qmlimportexporthandler.cpp0000644000015301777760000000277312323326002027735 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "qmlimportexporthandler.h" #include "../../../src/com/ubuntu/content/debug.h" #include namespace cuc = com::ubuntu::content; /*! * QmlImportExportHandler is for internal use only */ QmlImportExportHandler::QmlImportExportHandler(QObject *parent) : cuc::ImportExportHandler(parent) { TRACE() << Q_FUNC_INFO; } /*! * \reimp */ void QmlImportExportHandler::handle_import(com::ubuntu::content::Transfer *transfer) { TRACE() << Q_FUNC_INFO; Q_EMIT importRequested(transfer); } /*! * \reimp */ void QmlImportExportHandler::handle_export(com::ubuntu::content::Transfer *transfer) { TRACE() << Q_FUNC_INFO; Q_EMIT exportRequested(transfer); } /*! * \reimp */ void QmlImportExportHandler::handle_share(com::ubuntu::content::Transfer *transfer) { TRACE() << Q_FUNC_INFO; Q_EMIT shareRequested(transfer); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentpeermodel.cpp0000644000015301777760000001123012323326002026444 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contentpeermodel.h" #include namespace cuc = com::ubuntu::content; /*! * \qmltype ContentPeerModel * \instantiates ContentPeerModel * \inqmlmodule Ubuntu.Content * \brief A list of applications that can export or import a ContentType * * A ContentPeerModel provides a list of all applications that are registered * in the ContentHub as a source or destination of a ContentType * * See documentation for ContentPeer */ ContentPeerModel::ContentPeerModel(QObject *parent) : QObject(parent), m_contentType(ContentType::Unknown), m_handler(ContentHandler::Source), m_complete(false) { TRACE() << Q_FUNC_INFO; m_hub = cuc::Hub::Client::instance(); } /*! * \brief \reimp * \internal */ void ContentPeerModel::classBegin() { } /*! * \brief \reimp * \internal */ void ContentPeerModel::componentComplete() { m_complete = true; findPeers(); } /*! * \qmlproperty ContentType ContentPeerModel::contentType * * Specifies which ContentType discovered peers should support. */ ContentType::Type ContentPeerModel::contentType() { TRACE() << Q_FUNC_INFO; return m_contentType; } /*! * \brief ContentPeerModel::setContentType * \internal */ void ContentPeerModel::setContentType(ContentType::Type contentType) { TRACE() << Q_FUNC_INFO; if (m_contentType != contentType) { m_contentType = contentType; if (m_complete) { findPeers(); } Q_EMIT contentTypeChanged(); } } /*! * \brief ContentPeerModel::findPeers * \internal */ void ContentPeerModel::findPeers() { TRACE() << Q_FUNC_INFO; m_peers.clear(); QCoreApplication::processEvents(); if(m_contentType == ContentType::All) { appendPeersForContentType(ContentType::Documents); appendPeersForContentType(ContentType::Pictures); appendPeersForContentType(ContentType::Music); appendPeersForContentType(ContentType::Contacts); } else { appendPeersForContentType(m_contentType); } Q_EMIT findPeersCompleted(); } /*! * \brief ContentPeerModel::appendPeersForContentType * \internal */ void ContentPeerModel::appendPeersForContentType(ContentType::Type contentType) { TRACE() << Q_FUNC_INFO; const cuc::Type &hubType = ContentType::contentType2HubType(contentType); QVector hubPeers; if (m_handler == ContentHandler::Destination) { hubPeers = m_hub->known_destinations_for_type(hubType); } else if (m_handler == ContentHandler::Share) { hubPeers = m_hub->known_shares_for_type(hubType); } else { hubPeers = m_hub->known_sources_for_type(hubType); } Q_FOREACH (const cuc::Peer &hubPeer, hubPeers) { if(!hubPeer.id().isEmpty()) { ContentPeer *qmlPeer = new ContentPeer(); qmlPeer->setPeer(hubPeer); qmlPeer->setContentType(contentType); qmlPeer->setHandler(m_handler); if(qmlPeer->isDefaultPeer()) { m_peers.prepend(qmlPeer); } else { m_peers.append(qmlPeer); } Q_EMIT peersChanged(); } } } /*! * \qmlproperty ContentHandler ContentPeerModel::handler * * Specifies which ContentHandler discovered peers should support. */ ContentHandler::Handler ContentPeerModel::handler() { TRACE() << Q_FUNC_INFO; return m_handler; } /*! * \brief ContentPeerModel::setHandler * \internal */ void ContentPeerModel::setHandler(ContentHandler::Handler handler) { TRACE() << Q_FUNC_INFO; if (m_handler != handler) { m_handler = handler; if (m_complete) { findPeers(); } Q_EMIT handlerChanged(); } } /*! * \qmlproperty list ContentPeerModel::peers * * Provides a list of discovered peers matching the requested ContentType and ContentHandler. */ QQmlListProperty ContentPeerModel::peers() { TRACE() << Q_FUNC_INFO; return QQmlListProperty(this, m_peers); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenttransfer.h0000644000015301777760000000636512323326002025776 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTTRANSFER_H_ #define COM_UBUNTU_CONTENTTRANSFER_H_ #include "contentstore.h" #include #include #include #include #include class ContentItem; class ContentTransfer : public QObject { Q_OBJECT Q_ENUMS(State) Q_ENUMS(Direction) Q_ENUMS(SelectionType) Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(Direction direction READ direction CONSTANT) Q_PROPERTY(SelectionType selectionType READ selectionType WRITE setSelectionType NOTIFY selectionTypeChanged) Q_PROPERTY(QString store READ store NOTIFY storeChanged) Q_PROPERTY(QQmlListProperty items READ items NOTIFY itemsChanged) public: enum State { Created = com::ubuntu::content::Transfer::created, Initiated = com::ubuntu::content::Transfer::initiated, InProgress = com::ubuntu::content::Transfer::in_progress, Charged = com::ubuntu::content::Transfer::charged, Collected = com::ubuntu::content::Transfer::collected, Aborted = com::ubuntu::content::Transfer::aborted, Finalized = com::ubuntu::content::Transfer::finalized }; enum Direction { Import = com::ubuntu::content::Transfer::Import, Export = com::ubuntu::content::Transfer::Export, Share = com::ubuntu::content::Transfer::Share }; enum SelectionType { Single = com::ubuntu::content::Transfer::SelectionType::single, Multiple = com::ubuntu::content::Transfer::SelectionType::multiple }; ContentTransfer(QObject *parent = nullptr); State state() const; void setState(State state); Direction direction() const; SelectionType selectionType() const; void setSelectionType(SelectionType); QQmlListProperty items(); Q_INVOKABLE bool start(); Q_INVOKABLE bool finalize(); const QString store() const; Q_INVOKABLE void setStore(ContentStore *contentStore); com::ubuntu::content::Transfer *transfer() const; void setTransfer(com::ubuntu::content::Transfer *transfer); void collectItems(); Q_SIGNALS: void stateChanged(); void itemsChanged(); void selectionTypeChanged(); void storeChanged(); private Q_SLOTS: void updateState(); void updateStore(); void updateSelectionType(); private: com::ubuntu::content::Transfer *m_transfer; QList m_items; State m_state; Direction m_direction; SelectionType m_selectionType; com::ubuntu::content::Store m_store; }; #endif // COM_UBUNTU_CONTENTTRANSFER_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenthubplugin.cpp0000644000015301777760000000562312323326002026476 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "contenthubplugin.h" #include "../../../src/com/ubuntu/content/debug.h" #include "contenthandler.h" #include "contenthub.h" #include "contenticonprovider.h" #include "contentitem.h" #include "contentpeer.h" #include "contentpeermodel.h" #include "contentscope.h" #include "contentstore.h" #include "contenttransfer.h" #include "contenttype.h" #include #include #include #include #include /*! * \brief qml_content_hub function to unstatinate the ContentHub as a singleton in QML */ static QObject *qml_content_hub(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) Q_UNUSED(scriptEngine) TRACE() << Q_FUNC_INFO; return ContentHub::instance(); } /*! * \reimp */ void ContentHubPlugin::initializeEngine(QQmlEngine * engine, const char * uri) { Q_UNUSED(uri) TRACE() << Q_FUNC_INFO; QIcon::setThemeName("ubuntu-mobile"); QIcon::setThemeSearchPaths(QStringList() << ("/usr/share/icons/")); ContentIconProvider *iconProvider = ContentIconProvider::instance(); engine->addImageProvider("content-hub", iconProvider); } /*! * \reimp */ void ContentHubPlugin::registerTypes(const char *uri) { TRACE() << Q_FUNC_INFO; Q_ASSERT(uri == QLatin1String("Ubuntu.Content")); const int versionMajor = 0; const int versionMinor = 1; qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "ContentHandler", "Not creatable as an object, use only to retrieve handler enums (e.g. ContentHandler.Source)"); qmlRegisterSingletonType(uri, versionMajor, versionMinor, "ContentHub", qml_content_hub); qmlRegisterType(uri, versionMajor, versionMinor, "ContentItem"); qmlRegisterType(uri, versionMajor, versionMinor, "ContentPeer"); qmlRegisterType(uri, versionMajor, versionMinor, "ContentPeerModel"); qmlRegisterType(uri, versionMajor, versionMinor, "ContentScope"); qmlRegisterType(uri, versionMajor, versionMinor, "ContentStore"); qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "ContentTransfer", "created by hub"); qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "ContentType", "Use only the type"); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/ContentTransferHint.qml0000644000015301777760000000452012323326002027052 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Components.Popups 0.1 import Ubuntu.Content 0.1 /*! \qmltype ContentTransferHint \inqmlmodule Ubuntu.Content \brief Component that indicates that a transfer is active This component shows that the transfer is currently running, and the source application is active. It blocks all input during that time. Place this component on top of your view. See documentation for ContentHub to see an example */ Item { id: root /*! \qmlproperty ContentTransfer ContentTransferHint::activeTransfer \brief The ContentTransfer to monitor the status of. This should be set to the currently active ContentTransfer, which will then cause the ContentTransferHint to become visible while the transfer is in progress. */ property var activeTransfer opacity: internal.isTransferRunning ? 1.0 : 0.0 Component { id: dialog Dialog { id: dialogue ActivityIndicator { anchors.centerIn: parent running: internal.isTransferRunning } } } QtObject { id: internal property bool isTransferRunning: root.activeTransfer ? root.activeTransfer.state === ContentTransfer.InProgress || root.activeTransfer.state === ContentTransfer.Initiated : false property var dialogue onIsTransferRunningChanged: { if (isTransferRunning) { dialogue = PopupUtils.open(dialog); } else { PopupUtils.close(dialogue); } } } } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/qmlimportexporthandler.h0000644000015301777760000000276712323326002027405 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_QMLIMPORTEXPORTHANDLER_H_ #define COM_UBUNTU_QMLIMPORTEXPORTHANDLER_H_ #include namespace com { namespace ubuntu { namespace content { class Transfer; } } } class QmlImportExportHandler : public com::ubuntu::content::ImportExportHandler { Q_OBJECT public: QmlImportExportHandler(QObject *parent = nullptr); Q_INVOKABLE virtual void handle_import(com::ubuntu::content::Transfer *transfer); Q_INVOKABLE virtual void handle_export(com::ubuntu::content::Transfer *transfer); Q_INVOKABLE virtual void handle_share(com::ubuntu::content::Transfer *transfer); Q_SIGNALS: void importRequested(com::ubuntu::content::Transfer*); void exportRequested(com::ubuntu::content::Transfer*); void shareRequested(com::ubuntu::content::Transfer*); }; #endif // COM_UBUNTU_QMLIMPORTEXPORTHANDLER_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenthub.h0000644000015301777760000000450012323326002024715 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTHUB_H_ #define COM_UBUNTU_CONTENTHUB_H_ #include #include #include #include #include "contentpeer.h" #include "contenttransfer.h" class ContentStore; class QmlImportExportHandler; namespace com { namespace ubuntu { namespace content { class Hub; class Peer; class Store; class Type; class Transfer; } } } class ContentHub : public QObject { Q_OBJECT Q_PROPERTY(QQmlListProperty finishedImports READ finishedImports NOTIFY finishedImportsChanged) public: ContentHub(const ContentHub&) = delete; static ContentHub *instance(); Q_INVOKABLE void restoreImports(); QQmlListProperty finishedImports(); Q_INVOKABLE ContentTransfer* importContent(com::ubuntu::content::Peer peer); Q_INVOKABLE ContentTransfer* exportContent(com::ubuntu::content::Peer peer); Q_INVOKABLE ContentTransfer* shareContent(com::ubuntu::content::Peer peer); Q_SIGNALS: void importRequested(ContentTransfer *transfer); void exportRequested(ContentTransfer *transfer); void shareRequested(ContentTransfer *transfer); void finishedImportsChanged(); private Q_SLOTS: void handleImport(com::ubuntu::content::Transfer* transfer); void handleExport(com::ubuntu::content::Transfer* transfer); void handleShare(com::ubuntu::content::Transfer* transfer); void updateState(); private: QList m_finishedImports; QHash m_activeImports; com::ubuntu::content::Hub *m_hub; QmlImportExportHandler *m_handler; protected: ContentHub(QObject* = nullptr); }; #endif // COM_UBUNTU_CONTENTHUB_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentscope.h0000644000015301777760000000222312323326002025250 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTSCOPE_H_ #define COM_UBUNTU_CONTENTSCOPE_H_ #include #include class ContentScope : public QObject { Q_OBJECT Q_ENUMS(Scope) public: enum Scope { System = 0, User = 1, App = 2 }; ContentScope(QObject *parent = nullptr); static com::ubuntu::content::Scope contentScope2HubScope(int scope); static com::ubuntu::content::Scope contentScope2HubScope(Scope scope); }; #endif // COM_UBUNTU_CONTENTSCOPE_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenthandler.cpp0000644000015301777760000000233112323326035026115 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contenthandler.h" /*! \qmltype ContentHandler \instantiates ContentHandler \inqmlmodule Ubuntu.Content \brief Describes the type of transfer operation to perform \sa ContentHub \e {ContentHandler} is an enumeration of handler types: \table \header \li Handler \row \li ContentHandler.Source \row \li ContentHandler.Destination \row \li ContentHandler.Share \endtable */ ContentHandler::ContentHandler(QObject *parent) : QObject(parent) { TRACE() << Q_FUNC_INFO; } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/qmldir0000644000015301777760000000022412323326002023605 0ustar pbusernogroup00000000000000module Ubuntu.Content plugin ubuntu-content-hub-plugin ContentTransferHint 0.1 ContentTransferHint.qml ContentPeerPicker 0.1 ContentPeerPicker.qml content-hub-0.0+14.04.20140415/import/Ubuntu/Content/ContentPeerPicker.qml0000644000015301777760000002123012323326002026471 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ import QtQuick 2.0 import Ubuntu.Components 0.1 import Ubuntu.Components.Popups 0.1 import Ubuntu.Components.ListItems 0.1 as ListItem import Ubuntu.Content 0.1 /*! \qmltype ContentPeerPicker \inqmlmodule Ubuntu.Content \brief Component that allows users to select a source/destination for content transfer This component displays a list of applications, devices and services which are appropriate for transferring a given content type with. */ Item { id: root anchors.fill: parent visible: false /*! \qmlproperty ContentHandler handler \brief The ContentHandler to use when finding peers. */ property var handler /*! \qmlproperty ContentType contentType \brief The ContentType to use when finding peers. */ property var contentType /*! \qmlproperty bool showTitle \brief Determines whether the header should be displayed. This makes it possible to hide the header, which can be useful if embedding the picker within another page or popup. */ property alias showTitle: header.visible /*! \qmlproperty ContentPeer peer \brief The peer selected by the user. Once the peerSelected signal has been sent, this provides the ContentPeer which the user has selected. */ property var peer /*! \qmlproperty Loader customerPeerModelLoader \brief A Loader containing a ContentPeerModel. This can optionally be used to provide a pre-populated ContentPeerModel to this ContentPeerPicker. */ property var customPeerModelLoader property var completed: false /*! \qmlsignal peerSelected \brief Emitted when a user selects a peer. Once this signal has been emitted the selected peer can be accessed via the peer property. \c onPeerSelected */ signal peerSelected /*! \qmlsignal cancelPressed \brief Emitted when the user clicks the cancel button. The ContentPeerPicker will be hidden automatically when the user cancels the operations and the active ContentTransfer will be set to Aborted. \c onCancelPressed */ signal cancelPressed Header { id: header title: (handler === ContentHandler.Source) ? i18n.tr("Choose from") : (handler === ContentHandler.Destination ? i18n.tr("Open with") : i18n.tr("Share to")) } Loader { id: peerModelLoader active: false sourceComponent: ContentPeerModel { } onLoaded: { item.handler = root.handler; item.contentType = root.contentType; } } Component.onCompleted: { if (root.visible) { if (customPeerModelLoader) { customPeerModelLoader.active = true; } else { peerModelLoader.active = true; } } completed = true; } onVisibleChanged: { if (completed) { if (customPeerModelLoader) { customPeerModelLoader.active = true; } else { peerModelLoader.active = true; } } } onHandlerChanged: { if (!customPeerModelLoader && peerModelLoader.item) { appPeers.model = undefined; // Clear grid view peerModelLoader.item.handler = root.handler; appPeers.model = peerModelLoader.item.peers; } } onContentTypeChanged: { if (!customPeerModelLoader && peerModelLoader.item) { appPeers.model = undefined; // Clear grid view peerModelLoader.item.contentType = root.contentType; appPeers.model = peerModelLoader.item.peers; } } Component { id: peerDelegate Item { width: units.gu(13.5) height: units.gu(16) AbstractButton { width: parent.width height: icon.height + label.height UbuntuShape { id: icon anchors { top: parent.top horizontalCenter: parent.horizontalCenter } radius: "medium" width: units.gu(8) height: units.gu(7.5) image: Image { id: image objectName: "image" sourceSize { width: icon.width; height: icon.height } asynchronous: true cache: false source: "image://content-hub/" + modelData.appId horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter } } Label { id: label objectName: "label" anchors { baseline: icon.bottom baselineOffset: units.gu(2) left: parent.left right: parent.right leftMargin: units.gu(1) rightMargin: units.gu(1) } opacity: 0.9 fontSize: "small" elide: Text.ElideMiddle horizontalAlignment: Text.AlignHCenter text: modelData.name || modelData.appId } onClicked: { peer = modelData peerSelected() } } } } ListItem.Header { id: appTitle anchors.top: header.visible ? header.bottom : parent.top text: i18n.tr("Apps") } Rectangle { id: apps color: "#FFFFFF" height: devices.visible ? (parent.height / 2.4) : parent.height width: parent.width clip: true anchors { left: parent.left right: parent.right top: appTitle.bottom } Flickable { anchors.fill: parent ResponsiveGridView { id: appPeers anchors.fill: parent minimumHorizontalSpacing: units.gu(0.5) maximumNumberOfColumns: 6 delegateWidth: units.gu(11) delegateHeight: units.gu(9.5) verticalSpacing: units.gu(2) model: customPeerModelLoader ? customPeerModelLoader.item.peers : peerModelLoader.item.peers delegate: peerDelegate } } } ListItem.Header { id: devTitle // TODO: make this visible when we have a way to populate devices visible: false anchors { left: parent.left right: parent.right top: apps.bottom } text: i18n.tr("Devices") } Rectangle { id: devices // TODO: make this visible when we have a way to populate devices visible: false color: "#FFFFFF" width: parent.width radius: 0 anchors { left: parent.left right: parent.right top: devTitle.bottom bottom: cancelButton.top bottomMargin: units.gu(1) } Flickable { anchors.fill: parent ResponsiveGridView { id: devPeers anchors.fill: parent minimumHorizontalSpacing: units.gu(0.5) maximumNumberOfColumns: 6 delegateWidth: units.gu(11) delegateHeight: units.gu(9.5) verticalSpacing: units.gu(2) delegate: peerDelegate } } } Button { id: cancelButton text: "Cancel" anchors { left: parent.left bottom: parent.bottom margins: units.gu(1) } onClicked: { if(root.activeTransfer) { root.activeTransfer.state = ContentTransfer.Aborted; } cancelPressed(); } } } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenttransfer.cpp0000644000015301777760000002076512323326035026337 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "contenttransfer.h" #include "contentitem.h" #include "../../../src/com/ubuntu/content/debug.h" #include /*! * \qmltype ContentTransfer * \instantiates ContentTransfer * \inqmlmodule Ubuntu.Content * \brief Represents a transfer of content between two ContentPeers * * See documentation for ContentHub */ namespace cuc = com::ubuntu::content; ContentTransfer::ContentTransfer(QObject *parent) : QObject(parent), m_transfer(0), m_state(Aborted), m_direction(Import), m_selectionType(Single), m_store(0) { TRACE() << Q_FUNC_INFO; } /*! \qmlproperty ContentTransfer.State ContentTransfer::state \table \header \li {2, 1} \e {ContentTransfer.State} is an enumeration: \header \li State \li Description \row \li ContentTransfer.Created \li Transfer created, waiting to be initiated. \row \li ContentTransfer.Initiated \li Transfer has been initiated. \row \li ContentTransfer.InProgress \li Transfer is in progress. \row \li ContentTransfer.Charged \li Transfer is charged with items and ready to be collected. \row \li ContentTransfer.Collected \li Items in the transfer have been collected. \row \li ContentTransfer.Aborted \li Transfer has been aborted. \row \li ContentTransfer.Finalized \li Transfer has been finished and cleaned up. \endtable */ ContentTransfer::State ContentTransfer::state() const { TRACE() << Q_FUNC_INFO; return m_state; } void ContentTransfer::setState(ContentTransfer::State state) { TRACE() << Q_FUNC_INFO << state; if (!m_transfer) return; if (state == Charged && m_state == InProgress) { TRACE() << Q_FUNC_INFO << "Charged"; QVector hubItems; hubItems.reserve(m_items.size()); Q_FOREACH (const ContentItem *citem, m_items) { hubItems.append(citem->item()); } m_transfer->charge(hubItems); return; } else if (state == Aborted) { TRACE() << Q_FUNC_INFO << "Aborted"; m_transfer->abort(); } else updateState(); } /*! \qmlproperty ContentTransfer.Direction ContentTransfer::direction \brief ContentTransfer::direction indicates if this transferobject is used for import or export transaction \table \header \li {2, 1} \e {ContentTransfer.Direction} is an enumeration: \header \li Direction \li Description \row \li ContentTransfer.Import \li Transfer is a request to import content. \row \li ContentTransfer.Export \li Transfer is a request to export content. \row \li ContentTransfer.Share \li Transfer is a request to share content. \endtable */ ContentTransfer::Direction ContentTransfer::direction() const { return m_direction; } /*! \qmlproperty ContentTransfer.SelectionType ContentTransfer::selectionType \brief ContentTransfer::selectionType indicates if this transfer object allows single or multiple selection of items \table \header \li {2, 1} \e {ContentTransfer.SelectionType} is an enumeration: \header \li Type \li Description \row \li ContentTransfer.Single \li Transfer should contain a single item. \row \li ContentTransfer.Multiple \li Transfer can contain multiple items. \endtable */ ContentTransfer::SelectionType ContentTransfer::selectionType() const { return m_selectionType; } void ContentTransfer::setSelectionType(ContentTransfer::SelectionType type) { TRACE() << Q_FUNC_INFO << type; if (!m_transfer) return; if (m_state == Created && (m_selectionType != type)) { m_transfer->setSelectionType(static_cast(type)); } } /*! * \qmlproperty list ContentTransfer::items * * List of items included in the ContentTransfer */ QQmlListProperty ContentTransfer::items() { TRACE() << Q_FUNC_INFO; if (m_state == Charged) { collectItems(); } return QQmlListProperty(this, m_items); } /*! * \qmlmethod ContentTransfer::start() * * Start the transfer, this sets the State to ContentTransfer.Initiated */ bool ContentTransfer::start() { TRACE() << Q_FUNC_INFO << m_transfer->id() << ":" << m_state; if (m_state == Created) { return m_transfer->start(); } else { qWarning() << Q_FUNC_INFO << "Transfer can't be started"; return false; } } /*! * \qmlmethod ContentTransfer::finalize() * * Sets State to ContentTransfer.Finalized and cleans up temporary files */ bool ContentTransfer::finalize() { TRACE() << Q_FUNC_INFO; return m_transfer->finalize(); } /*! * \qmlproperty string ContentTransfer::store * ContentStore where the ContentTransfer will add items */ const QString ContentTransfer::store() const { TRACE() << Q_FUNC_INFO; return m_transfer->store().uri(); } void ContentTransfer::setStore(ContentStore* contentStore) { TRACE() << Q_FUNC_INFO; if (!m_transfer) { qWarning() << Q_FUNC_INFO << "invalid transfer"; return; } if(contentStore->store() != nullptr) { m_transfer->setStore(contentStore->store()); } } /*! * \brief ContentTransfer::transfer * \internal */ com::ubuntu::content::Transfer *ContentTransfer::transfer() const { TRACE() << Q_FUNC_INFO; return m_transfer; } /*! * \brief ContentTransfer::setTransfer * \internal */ void ContentTransfer::setTransfer(com::ubuntu::content::Transfer *transfer) { if (m_transfer) { qWarning() << Q_FUNC_INFO << "the transfer object was already set"; return; } if (!transfer) { qWarning() << Q_FUNC_INFO << "No valid transfer object passed:" << transfer; return; } m_transfer = transfer; m_direction = static_cast(transfer->direction()); TRACE() << Q_FUNC_INFO << "Direction:" << m_direction; connect(m_transfer, SIGNAL(selectionTypeChanged()), this, SLOT(updateSelectionType())); connect(m_transfer, SIGNAL(storeChanged()), this, SLOT(updateStore())); connect(m_transfer, SIGNAL(stateChanged()), this, SLOT(updateState())); updateSelectionType(); updateStore(); updateState(); } /*! * \brief ContentTransfer::collectItems gets the items out of the transfer object * \internal */ void ContentTransfer::collectItems() { TRACE() << Q_FUNC_INFO; if (m_state != Charged) return; qDeleteAll(m_items); m_items.clear(); QVector transfereditems = m_transfer->collect(); Q_FOREACH (const cuc::Item &hubItem, transfereditems) { ContentItem *qmlItem = new ContentItem(this); qmlItem->setItem(hubItem); m_items.append(qmlItem); } Q_EMIT itemsChanged(); } /*! * \brief ContentTransfer::updateState update the state from the hub transfer object * \internal */ void ContentTransfer::updateState() { TRACE() << Q_FUNC_INFO << m_transfer->state(); if (!m_transfer) { TRACE() << Q_FUNC_INFO << "Invalid transfer"; return; } m_state = static_cast(m_transfer->state()); Q_EMIT stateChanged(); } /*! * \brief ContentTransfer::updateSelectionType update the selectionType from the hub transfer object * \internal */ void ContentTransfer::updateSelectionType() { TRACE() << Q_FUNC_INFO; if (!m_transfer) { TRACE() << Q_FUNC_INFO << "Invalid transfer"; return; } m_selectionType = static_cast(m_transfer->selectionType()); Q_EMIT selectionTypeChanged(); } /*! * \brief ContentTransfer::updateStore update the store from the hub transfer object * \internal */ void ContentTransfer::updateStore() { TRACE() << Q_FUNC_INFO; if (!m_transfer) { TRACE() << Q_FUNC_INFO << "Invalid transfer"; return; } m_store = m_transfer->store(); Q_EMIT storeChanged(); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenthandler.h0000644000015301777760000000175512323326002025565 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTHANDLER_H_ #define COM_UBUNTU_CONTENTHANDLER_H_ #include class ContentHandler : public QObject { Q_OBJECT Q_ENUMS(Handler) public: enum Handler { Source = 0, Destination = 1, Share = 2 }; ContentHandler(QObject *parent = nullptr); }; #endif // COM_UBUNTU_CONTENTHANDLER_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/CMakeLists.txt0000644000015301777760000000542012323326002025135 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . project(content-hub-plugin) find_package(Qt5Quick REQUIRED) set(CMAKE_AUTOMOC TRUE) execute_process( COMMAND qmake -query QT_INSTALL_QML OUTPUT_VARIABLE QT_INSTALL_QML OUTPUT_STRIP_TRAILING_WHITESPACE ) set(CONTENT_HUB_IMPORTS_DIR "${QT_INSTALL_QML}/Ubuntu/Content") set(PLUGIN ubuntu-content-hub-plugin) add_definitions(-DQT_NO_KEYWORDS) include_directories( ${CMAKE_SOURCE_DIR} ${NIH_INCLUDE_DIRS} ${NIH_DBUS_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} ) set(PLUGIN_HDRS contenthandler.h contenthub.h contenthubplugin.h contenticonprovider.h contentitem.h contentpeer.h contentpeermodel.h contentscope.h contentstore.h contenttransfer.h contenttype.h qmlimportexporthandler.h ) set(PLUGIN_SRC contenthandler.cpp contenthub.cpp contenthubplugin.cpp contenticonprovider.cpp contentitem.cpp contentpeer.cpp contentpeermodel.cpp contentscope.cpp contentstore.cpp contenttransfer.cpp contenttype.cpp qmlimportexporthandler.cpp ../../../src/com/ubuntu/content/debug.cpp ) add_library(${PLUGIN} MODULE ${PLUGIN_SRC} ${PLUGIN_HDRS}) qt5_use_modules(${PLUGIN} Core Qml Quick DBus) target_link_libraries( ${PLUGIN} content-hub ${NIH_LIBRARIES} ${NIH_DBUS_LIBRARIES} ) install(TARGETS ${PLUGIN} DESTINATION ${CONTENT_HUB_IMPORTS_DIR}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/qmldir DESTINATION ${CONTENT_HUB_IMPORTS_DIR}) file(GLOB QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml qmldir) install(FILES ${QML_FILES} DESTINATION ${CONTENT_HUB_IMPORTS_DIR}) if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) # copy qml files and assets over to build dir to be able to import them uninstalled foreach(_file ${QML_FILES}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_file} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${CMAKE_CURRENT_BINARY_DIR}/${_file}) endforeach(_file) add_custom_target(copy_files_to_build_dir DEPENDS ${QML_FILES}) add_dependencies(${PLUGIN} copy_files_to_build_dir) endif() content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentscope.cpp0000644000015301777760000000347512323326035025623 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contentscope.h" /*! \qmltype ContentScope \instantiates ContentScope \inqmlmodule Ubuntu.Content \brief Used with a ContentStore to specify the destination location for a transfer \sa ContentStore \e {ContentScope} is an enumeration of scope types: \table \header \li Scope \row \li ContentScope.System \row \li ContentScope.User \row \li ContentScope.App \endtable */ ContentScope::ContentScope(QObject *parent) : QObject(parent) { TRACE() << Q_FUNC_INFO; } /*! * \brief ContentScope::contentScope2HubScope converts a ContentScope::Scope to a * com::ubuntu::content::Scope * \internal */ com::ubuntu::content::Scope ContentScope::contentScope2HubScope(int scope) { Scope cscope = static_cast(scope); TRACE() << Q_FUNC_INFO << cscope; return contentScope2HubScope(cscope); } /*! * \brief ContentScope::contentScope2HubScope converts a ContentScope::Scope to a * com::ubuntu::content::Scope * \internal */ com::ubuntu::content::Scope ContentScope::contentScope2HubScope(Scope scope) { return static_cast(scope); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenthub.cpp0000644000015301777760000002153112323326035025261 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contenthub.h" #include "contentpeer.h" #include "contentstore.h" #include "contenttransfer.h" #include "contenttype.h" #include "qmlimportexporthandler.h" #include #include #include #include /*! * \qmltype ContentHub * \instantiates ContentHub * \inqmlmodule Ubuntu.Content * \brief The central manager for all content operations * * Example usage for importing content: * \qml * import QtQuick 2.0 * import Ubuntu.Components 0.1 * import Ubuntu.Content 0.1 * * MainView { * id: root * width: units.gu(60) * height: units.gu(90) * property list importItems * property var activeTransfer * * ContentPeer { * id: picSourceSingle * contentType: ContentType.Pictures * handler: ContentHandler.Source * selectionType: ContentTransfer.Single * } * * ContentPeer { * id: picSourceMulti * contentType: ContentType.Pictures * handler: ContentHandler.Source * selectionType: ContentTransfer.Multiple * } * * Row { * Button { * text: "Import single item" * onClicked: { * activeTransfer = picSourceSingle.request() * } * } * * Button { * text: "Import multiple items" * onClicked: { * activeTransfer = picSourceMulti.request() * } * } * } * * ContentTransferHint { * id: importHint * anchors.fill: parent * activeTransfer: root.activeTransfer * } * * Connections { * target: root.activeTransfer * onStateChanged: { * if (root.activeTransfer.state === ContentTransfer.Charged) * importItems = root.activeTransfer.items; * } * } * } * \endqml * * Example usage for providing a content export: * \qml * import QtQuick 2.0 * import Ubuntu.Content 0.1 * * Rectangle { * property list selectedItems * Connections { * target: ContentHub * onExportRequested: { * // show content picker * transfer.items = selectedItems; * transfer.state = ContentTransfer.Charged; * } * } * } * \endqml */ namespace cuc = com::ubuntu::content; ContentHub::ContentHub(QObject *parent) : QObject(parent), m_hub(0) { TRACE() << Q_FUNC_INFO; m_hub = cuc::Hub::Client::instance(); m_handler = new QmlImportExportHandler(this); m_hub->register_import_export_handler(m_handler); connect(m_handler, SIGNAL(importRequested(com::ubuntu::content::Transfer*)), this, SLOT(handleImport(com::ubuntu::content::Transfer*))); connect(m_handler, SIGNAL(exportRequested(com::ubuntu::content::Transfer*)), this, SLOT(handleExport(com::ubuntu::content::Transfer*))); connect(m_handler, SIGNAL(shareRequested(com::ubuntu::content::Transfer*)), this, SLOT(handleShare(com::ubuntu::content::Transfer*))); } ContentHub *ContentHub::instance() { TRACE() << Q_FUNC_INFO; static ContentHub *contentHub = new ContentHub(nullptr); return contentHub; } /*! * \brief ContentHub::importContent creates a ContentTransfer object * \a type * \a peer * \internal */ ContentTransfer* ContentHub::importContent(cuc::Peer peer) { TRACE() << Q_FUNC_INFO; cuc::Transfer *hubTransfer = m_hub->create_import_from_peer(peer); ContentTransfer *qmlTransfer = new ContentTransfer(this); qmlTransfer->setTransfer(hubTransfer); m_activeImports.insert(hubTransfer, qmlTransfer); return qmlTransfer; } /*! * \brief ContentHub::exportContent creates a ContentTransfer object * \a type * \a peer * \internal */ ContentTransfer* ContentHub::exportContent(cuc::Peer peer) { TRACE() << Q_FUNC_INFO; cuc::Transfer *hubTransfer = m_hub->create_export_to_peer(peer); ContentTransfer *qmlTransfer = new ContentTransfer(this); qmlTransfer->setTransfer(hubTransfer); m_activeImports.insert(hubTransfer, qmlTransfer); return qmlTransfer; } /*! * \brief ContentHub::shareContent creates a ContentTransfer object * \a type * \a peer * \internal */ ContentTransfer* ContentHub::shareContent(cuc::Peer peer) { TRACE() << Q_FUNC_INFO; cuc::Transfer *hubTransfer = m_hub->create_share_to_peer(peer); ContentTransfer *qmlTransfer = new ContentTransfer(this); qmlTransfer->setTransfer(hubTransfer); m_activeImports.insert(hubTransfer, qmlTransfer); return qmlTransfer; } /*! * \qmlmethod ContentHub::restoreImports() * \internal */ void ContentHub::restoreImports() { TRACE() << Q_FUNC_INFO; } /*! * \qmlproperty list ContentHub::finishedImports * \internal */ QQmlListProperty ContentHub::finishedImports() { TRACE() << Q_FUNC_INFO; return QQmlListProperty(this, m_finishedImports); } /*! * \brief ContentHub::handleImport handles an incoming request for importing content * \internal */ void ContentHub::handleImport(com::ubuntu::content::Transfer *transfer) { TRACE() << Q_FUNC_INFO; ContentTransfer *qmlTransfer = nullptr; if (m_activeImports.contains(transfer)) { qmlTransfer = m_activeImports.take(transfer); qmlTransfer->collectItems(); } else { // If we don't have a reference to the transfer, it was created // by another handler so this would be an Import qmlTransfer = new ContentTransfer(this); qmlTransfer->setTransfer(transfer); connect(qmlTransfer, SIGNAL(stateChanged()), this, SLOT(updateState())); qmlTransfer->collectItems(); Q_EMIT importRequested(qmlTransfer); } // FIXME: maybe we need to emit something else here // if (qmlTransfer->state() == ContentTransfer::Charged) // Q_EMIT importRequested(qmlTransfer); m_finishedImports.append(qmlTransfer); Q_EMIT finishedImportsChanged(); } /*! * \brief ContentHub::handleExport handles an incoming request for exporting content * \internal */ void ContentHub::handleExport(com::ubuntu::content::Transfer *transfer) { TRACE() << Q_FUNC_INFO; ContentTransfer *qmlTransfer = nullptr; if (m_activeImports.contains(transfer)) qmlTransfer = m_activeImports.take(transfer); else { // If we don't have a reference to the transfer, it was created // by another handler so this would be an Import qmlTransfer = new ContentTransfer(this); qmlTransfer->setTransfer(transfer); m_activeImports.insert(transfer, qmlTransfer); connect(qmlTransfer, SIGNAL(stateChanged()), this, SLOT(updateState())); Q_EMIT exportRequested(qmlTransfer); } m_finishedImports.append(qmlTransfer); Q_EMIT finishedImportsChanged(); } /*! * \brief ContentHub::handleExport handles an incoming request for sharing content * \internal */ void ContentHub::handleShare(com::ubuntu::content::Transfer *transfer) { TRACE() << Q_FUNC_INFO; ContentTransfer *qmlTransfer = nullptr; if (m_activeImports.contains(transfer)) { qmlTransfer = m_activeImports.take(transfer); qmlTransfer->collectItems(); } else { // If we don't have a reference to the transfer, it was created // by another handler so this would be an Import qmlTransfer = new ContentTransfer(this); qmlTransfer->setTransfer(transfer); connect(qmlTransfer, SIGNAL(stateChanged()), this, SLOT(updateState())); qmlTransfer->collectItems(); Q_EMIT shareRequested(qmlTransfer); } m_finishedImports.append(qmlTransfer); Q_EMIT finishedImportsChanged(); } void ContentHub::updateState() { TRACE() << Q_FUNC_INFO; } /*! * \qmlsignal ContentHub::importRequested(ContentTransfer transfer) * * The signal is triggered when an import is requested. */ /*! * \qmlsignal ContentHub::exportRequested(ContentTransfer transfer) * * The signal is triggered when an export is requested. */ /*! * \qmlsignal ContentHub::shareRequested(ContentTransfer transfer) * * The signal is triggered when a share is requested. */ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenttype.h0000644000015301777760000000235012323326002025121 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTTYPE_H_ #define COM_UBUNTU_CONTENTTYPE_H_ #include #include #include class ContentType : public QObject { Q_OBJECT Q_ENUMS(Type) public: enum Type { All = -1, Unknown = 0, Documents = 1, Pictures = 2, Music = 3, Contacts = 4 }; ContentType(QObject *parent = nullptr); static const com::ubuntu::content::Type &contentType2HubType(int type); static const com::ubuntu::content::Type &contentType2HubType(Type type); }; #endif // COM_UBUNTU_CONTENTTYPE_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentpeermodel.h0000644000015301777760000000413612323326002026120 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTPEERMODEL_H_ #define COM_UBUNTU_CONTENTPEERMODEL_H_ #include "contentpeer.h" #include "contenttype.h" #include "contenthandler.h" #include #include #include #include #include class ContentPeerModel : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(ContentType::Type contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged) Q_PROPERTY(ContentHandler::Handler handler READ handler WRITE setHandler NOTIFY handlerChanged) Q_PROPERTY(QQmlListProperty peers READ peers NOTIFY peersChanged) public: ContentPeerModel(QObject *parent = nullptr); void classBegin(); void componentComplete(); ContentType::Type contentType(); void setContentType(ContentType::Type contentType); void appendPeersForContentType(ContentType::Type contentType); ContentHandler::Handler handler(); void setHandler(ContentHandler::Handler handler); QQmlListProperty peers(); Q_SIGNALS: void contentTypeChanged(); void handlerChanged(); void peersChanged(); void findPeersCompleted(); public Q_SLOTS: void findPeers(); private: com::ubuntu::content::Hub *m_hub; ContentType::Type m_contentType; ContentHandler::Handler m_handler; QList m_peers; bool m_complete; }; #endif // COM_UBUNTU_CONTENTPEERMODEL_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenticonprovider.h0000644000015301777760000000224512323326002026646 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTICONPROVIDER_H_ #define COM_UBUNTU_CONTENTICONPROVIDER_H_ #include #include #include #include class ContentIconProvider : public QQuickImageProvider { public: ContentIconProvider(); static ContentIconProvider *instance(); QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); void addImage(QString appId, QImage image); private: QMap *appIdImageMap; }; #endif // COM_UBUNTU_CONTENTICONPROVIDER_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentitem.cpp0000644000015301777760000000423612323326002025436 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "contentitem.h" #include "../../../src/com/ubuntu/content/debug.h" /*! * \qmltype ContentItem * \instantiates ContentItem * \inqmlmodule Ubuntu.Content * \brief Content that can be imported or exported from a ContentPeer * * A ContentItem is an item that can be imported or exported from a ContentPeer * * See documentation for ContentHub */ namespace cuc = com::ubuntu::content; ContentItem::ContentItem(QObject *parent) : QObject(parent) { TRACE() << Q_FUNC_INFO; } /*! * \qmlproperty string ContentItem::name * \internal */ const QString &ContentItem::name() const { TRACE() << Q_FUNC_INFO; return m_name; } void ContentItem::setName(const QString &name) { TRACE() << Q_FUNC_INFO; if (name == m_name) return; m_name = name; Q_EMIT nameChanged(); } /*! * \qmlproperty url ContentItem::url * * URL of the content data */ const QUrl &ContentItem::url() const { TRACE() << Q_FUNC_INFO; return m_item.url(); } void ContentItem::setUrl(const QUrl &url) { TRACE() << Q_FUNC_INFO; if (url == this->url()) return; m_item = cuc::Item(url); Q_EMIT urlChanged(); } /*! * \brief ContentItem::item * \internal */ const com::ubuntu::content::Item &ContentItem::item() const { TRACE() << Q_FUNC_INFO; return m_item; } /*! * \brief ContentItem::setItem * \internal */ void ContentItem::setItem(const com::ubuntu::content::Item &item) { TRACE() << Q_FUNC_INFO; if (item == m_item) return; m_item = item; Q_EMIT urlChanged(); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentstore.cpp0000644000015301777760000000541112323326035025636 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "../../../src/com/ubuntu/content/debug.h" #include "contentpeer.h" #include "contentstore.h" #include "contenttype.h" /*! * \qmltype ContentStore * \instantiates ContentStore * \inqmlmodule Ubuntu.Content * \brief Sets the type of location that content should be transferred to * * A ContentStore allows for the permanent storage of a transfered item. * * See documentation for ContentHub and ContentScope */ namespace cuc = com::ubuntu::content; ContentStore::ContentStore(QObject *parent) : QObject(parent), m_store(0), m_scope(ContentScope::System) { TRACE() << Q_FUNC_INFO; m_hub = cuc::Hub::Client::instance(); } /*! * \qmlproperty uri ContentStore::uri * * URI of the content store */ const QString &ContentStore::uri() const { static const QString __empty; TRACE() << Q_FUNC_INFO; if ( ! m_store) { qWarning() << "Accessing ContentStore uri with NULL internal store"; return __empty; } return m_store->uri(); } /*! * \brief ContentStore::store * \internal */ const com::ubuntu::content::Store *ContentStore::store() const { TRACE() << Q_FUNC_INFO; return m_store; } /*! * \brief ContentStore::setStore * \internal */ void ContentStore::setStore(const com::ubuntu::content::Store *store) { TRACE() << Q_FUNC_INFO; m_store = store; Q_EMIT uriChanged(); } /*! * \qmlproperty ContentScope ContentStore::scope * * Specifies the ContentScope for this store. */ ContentScope::Scope ContentStore::scope() { TRACE() << Q_FUNC_INFO; return m_scope; } /*! * \brief ContentStore::setScope * \internal */ void ContentStore::setScope(ContentScope::Scope scope) { TRACE() << Q_FUNC_INFO; m_scope = scope; Q_EMIT scopeChanged(); } /*! * \brief ContentStore::updateStore * \internal */ void ContentStore::updateStore(ContentType::Type contentType) { TRACE() << Q_FUNC_INFO; com::ubuntu::content::Scope hubScope = ContentScope::contentScope2HubScope(m_scope); const com::ubuntu::content::Type &hubType = ContentType::contentType2HubType(contentType); setStore(m_hub->store_for_scope_and_type(hubScope, hubType)); } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contenttype.cpp0000644000015301777760000000444312323326035025467 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #include "contenttype.h" #include "../../../src/com/ubuntu/content/debug.h" /*! \qmltype ContentType \instantiates ContentType \inqmlmodule Ubuntu.Content \brief Describes the type of content to transfer \sa ContentHub \e {ContentType} is an enumeration of well known content types: \table \header \li Type \li Description \row \li ContentType.Uknown \li Unknown type \row \li ContentType.Documents \li Documents \row \li ContentType.Pictures \li Pictures \row \li ContentType.Music \li Music \row \li ContentType.Contacts \li Contacts \row \li ContentType.All \li Any of the above content types \endtable */ namespace cuc = com::ubuntu::content; ContentType::ContentType(QObject *parent) : QObject(parent) { TRACE() << Q_FUNC_INFO; } /*! * \brief ContentType::contentType2HubType converts a ContentType::Type to a * com::ubuntu::content::Type * \internal */ const com::ubuntu::content::Type &ContentType::contentType2HubType(int type) { Type ctype = static_cast(type); TRACE() << Q_FUNC_INFO << ctype; return contentType2HubType(ctype); } /*! * \brief ContentType::contentType2HubType converts a ContentType::Type to a * com::ubuntu::content::Type * \internal */ const com::ubuntu::content::Type &ContentType::contentType2HubType(Type type) { switch(type) { case Documents: return cuc::Type::Known::documents(); case Pictures: return cuc::Type::Known::pictures(); case Music: return cuc::Type::Known::music(); case Contacts: return cuc::Type::Known::contacts(); default: return cuc::Type::unknown(); } } content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentitem.h0000644000015301777760000000267112323326002025104 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTITEM_H_ #define COM_UBUNTU_CONTENTITEM_H_ #include #include #include #include class ContentItem : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) public: ContentItem(QObject *parent = nullptr); const QString &name() const; void setName(const QString &name); const QUrl &url() const; void setUrl(const QUrl &url); const com::ubuntu::content::Item &item() const; void setItem(const com::ubuntu::content::Item &item); Q_SIGNALS: void nameChanged(); void urlChanged(); private: QString m_name; com::ubuntu::content::Item m_item; }; #endif // COM_UBUNTU_CONTENTITEM_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/Content/contentstore.h0000644000015301777760000000314512323326002025277 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * 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; version 3. * * This program 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 . */ #ifndef COM_UBUNTU_CONTENTSTORE_H_ #define COM_UBUNTU_CONTENTSTORE_H_ #include "contentscope.h" #include "contenttype.h" #include #include #include #include class ContentStore : public QObject { Q_OBJECT Q_PROPERTY(QString uri READ uri NOTIFY uriChanged) Q_PROPERTY(ContentScope::Scope scope READ scope WRITE setScope NOTIFY scopeChanged) public: ContentStore(QObject *parent = nullptr); const QString &uri() const; const com::ubuntu::content::Store *store() const; void setStore(const com::ubuntu::content::Store *store); ContentScope::Scope scope(); void setScope(ContentScope::Scope scope); void updateStore(ContentType::Type type); Q_SIGNALS: void uriChanged(); void scopeChanged(); private: com::ubuntu::content::Hub *m_hub; const com::ubuntu::content::Store *m_store; ContentScope::Scope m_scope; }; #endif // COM_UBUNTU_CONTENTSTORE_H_ content-hub-0.0+14.04.20140415/import/Ubuntu/CMakeLists.txt0000644000015301777760000000117212323326002023523 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . add_subdirectory(Content) content-hub-0.0+14.04.20140415/import/CMakeLists.txt0000644000015301777760000000117112323326002022240 0ustar pbusernogroup00000000000000# Copyright © 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 warranty of # MERCHANTABILITY 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 . add_subdirectory(Ubuntu) content-hub-0.0+14.04.20140415/README0000644000015301777760000000213412323326002017046 0ustar pbusernogroup00000000000000What is content-hub? -------------------- content-hub is a mediation service to let applications share content between them even if they are not running at the same time. For a more detailed description, please have a look at: doc/Mainpage.md How do I get all building dependencies? --------------------------------------- Build dependencies are already listed in the debian/control file. To get them use the following command: sudo apt-get build-dep content-hub How do I compile the code? -------------------------- To compile the code run the following command from the branch directory: mkdir build cd build cmake .. make How do I run the test cases? ---------------------------- To run the test cases use the following command: cd build/tests dbus-test-runner -t make -p test How do I build the packages? ---------------------------- To build the pacakges run the following command: bzr builddeb How do I install the code? -------------------------- One way to do it one the code is compiled is: make install However, the recommended way to do it is by installing the packages built manually. content-hub-0.0+14.04.20140415/COPYING.LGPL0000644000015301777760000001674312323326002017771 0ustar pbusernogroup00000000000000 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.