clickmanager-plugin-0.1+14.04.20140306/0000755000015201777760000000000012306037572017667 5ustar pbusernogroup00000000000000clickmanager-plugin-0.1+14.04.20140306/tests/0000755000015201777760000000000012306037572021031 5ustar pbusernogroup00000000000000clickmanager-plugin-0.1+14.04.20140306/tests/fakeprocess.cpp0000644000015201777760000000300012306037363024031 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "fakeprocess.h" #include #include #include namespace ClickPlugin { FakeProcess::FakeProcess(QObject *parent) : QObject(parent) { } void FakeProcess::start(QString command, QStringList args) { if(command == "click") { QString path = QDir::currentPath(); path.append("/click.result"); this->m_content.clear(); QFile file(path); file.open(QIODevice::ReadOnly); QTextStream in(&file); while(!in.atEnd()) { QString line = in.readLine(); this->m_content.append(line); } file.close(); emit this->finished(0); } } QString FakeProcess::readAllStandardOutput() { return this->m_content; } void FakeProcess::startDetached(QString command, QStringList args) { } } clickmanager-plugin-0.1+14.04.20140306/tests/tests.pro0000644000015201777760000000317412306037363022720 0ustar pbusernogroup00000000000000QT += core qml quick network testlib dbus xml QT -= gui TARGET = clickmanager_test CONFIG += console testcase CONFIG -= app_bundle TEMPLATE = app SOURCES += \ ../src/clickmanager_plugin.cpp \ ../src/clickmanager.cpp \ ../src/network/network.cpp \ ../src/application.cpp \ ../src/download/downloader.cpp \ ../src/download/downloadmanager.cpp \ ../src/download/downloadtrackeradaptor.cpp \ ../src/download_tracker.cpp \ test_main.cpp \ testapplication.cpp \ testclickmanager.cpp \ fakenetwork.cpp \ fakedownloader.cpp \ fakeprocess.cpp \ ../src/download/download_struct.cpp \ ../src/download/group_download_struct.cpp \ ../src/download/hash_algorithm.cpp \ fakessoservice.cpp HEADERS += \ ../src/clickmanager_plugin.h \ ../src/clickmanager.h \ ../src/network/network.h \ ../src/application.h \ ../src/download/downloader.h \ ../src/download/downloadmanager.h \ ../src/download/metatypes.h \ ../src/download/downloadtrackeradaptor.h \ ../src/download_tracker.h \ testapplication.h \ testclickmanager.h \ fakenetwork.h \ fakedownloader.h \ fakeprocess.h \ ../src/download/download_struct.h \ ../src/download/group_download_struct.h \ ../src/download/hash_algorithm.h \ fakessoservice.h QMAKE_CXXFLAGS += -I /usr/include/ubuntuoneauth-2.0 -I /usr/include/signon-qt5 -I /usr/include/accounts-qt5 LIBS += -lapt-pkg -lubuntuoneauth-2.0 -lsignon-qt5 -laccounts-qt5 INCLUDEPATH += ../src/ DEFINES += SRCDIR=\\\"$$PWD/\\\" DEFINES += TESTS # Do not install the tests target.CONFIG += no_default_install clickmanager-plugin-0.1+14.04.20140306/tests/testapplication.h0000644000015201777760000000172612306037363024411 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef TESTAPPLICATION_H #define TESTAPPLICATION_H #include #include namespace ClickPlugin { class TestApplication : public QObject { Q_OBJECT private slots: void testCompareVersion(); }; } #endif // TESTAPPLICATION_H clickmanager-plugin-0.1+14.04.20140306/tests/fakessoservice.cpp0000644000015201777760000000044712306037363024554 0ustar pbusernogroup00000000000000#include "fakessoservice.h" namespace ClickPlugin { FakeSsoService::FakeSsoService(QObject *parent) : QObject(parent) { } void FakeSsoService::getCredentials() { Token token("token_key", "token_secret", "consumer_key", "consumer_secret"); emit this->credentialsFound(token); } } clickmanager-plugin-0.1+14.04.20140306/tests/testclickmanager.h0000644000015201777760000000231312306037363024517 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef TESTCLICKMANAGER_H #define TESTCLICKMANAGER_H #include #include namespace ClickPlugin { class TestClickManager : public QObject { Q_OBJECT public slots: void slotModelChanged(); private slots: void cleanup(); void testCheckUpdatesModelSignal(); void testCheckUpdatesUpdateSignal(); void testStartDownload(); void testTokenObtained(); void testDownloadNotCreated(); private: int m_signal_counter; }; } #endif // TESTCLICKMANAGER_H clickmanager-plugin-0.1+14.04.20140306/tests/fakeprocess.h0000644000015201777760000000227512306037363023513 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef FAKEPROCESS_H #define FAKEPROCESS_H #include #include #include namespace ClickPlugin { class FakeProcess : public QObject { Q_OBJECT public: explicit FakeProcess(QObject *parent = 0); void start(QString command, QStringList args); void startDetached(QString command, QStringList args); QString readAllStandardOutput(); signals: void finished(int); private: QString m_content; }; } #endif // FAKEPROCESS_H clickmanager-plugin-0.1+14.04.20140306/tests/fakessoservice.h0000644000015201777760000000062412306037363024216 0ustar pbusernogroup00000000000000#ifndef FAKESSOSERVICE_H #define FAKESSOSERVICE_H #include #include using namespace UbuntuOne; namespace ClickPlugin { class FakeSsoService : public QObject { Q_OBJECT public: explicit FakeSsoService(QObject *parent = 0); void getCredentials(); signals: void credentialsFound(const Token&); void credentialsNotFound(); }; } #endif // FAKESSOSERVICE_H clickmanager-plugin-0.1+14.04.20140306/tests/fakenetwork.h0000644000015201777760000000263212306037363023523 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef FAKENETWORK_H #define FAKENETWORK_H #include #include #include #include "application.h" namespace ClickPlugin { class FakeNetwork : public QObject { Q_OBJECT public: explicit FakeNetwork(QObject *parent = 0); void checkForNewVersions(QHash &apps); void getResourceUrl(QString packagename); void getClickToken(Application* app, const QString& url, const QString& authHeader); signals: void updatesFound(); void updatesNotFound(); void errorOccurred(); void downloadUrlFound(QString packagename, QString url); void clickTokenObtained(Application* app, const QString& clickToken); }; } #endif // FAKENETWORK_H clickmanager-plugin-0.1+14.04.20140306/tests/test_main.cpp0000644000015201777760000000203412306037363023515 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include "testapplication.h" #include "testclickmanager.h" using namespace ClickPlugin; int main() { TestApplication test_application; TestClickManager test_click; int result = 0; result += QTest::qExec(&test_application); result += QTest::qExec(&test_click); return result; } clickmanager-plugin-0.1+14.04.20140306/tests/testapplication.cpp0000644000015201777760000000211312306037363024733 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "testapplication.h" #include #include "application.h" namespace ClickPlugin { void TestApplication::testCompareVersion() { Application app; app.initializeApplication("package.name", "title", "1.1"); QCOMPARE(app.updateRequired(), false); QString version("1.4"); app.setRemoteVersion(version); QCOMPARE(app.updateRequired(), true); } } clickmanager-plugin-0.1+14.04.20140306/tests/fakenetwork.cpp0000644000015201777760000000273212306037363024057 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "fakenetwork.h" namespace ClickPlugin { FakeNetwork::FakeNetwork(QObject *parent) : QObject(parent) { } void FakeNetwork::checkForNewVersions(QHash &apps) { if(apps.contains("com.ubuntu.developer.xda-app")) { Application* app = apps.value("com.ubuntu.developer.xda-app"); QString version("0.5.2ubuntu2"); app->setRemoteVersion(version); emit this->updatesFound(); } } void FakeNetwork::getResourceUrl(QString packagename) { emit this->downloadUrlFound(packagename, "http://canonical.com"); } void FakeNetwork::getClickToken(Application* app, const QString& url, const QString& authHeader) { QString fakeHeader("x-click-token-header"); emit this->clickTokenObtained(app, fakeHeader); } } clickmanager-plugin-0.1+14.04.20140306/tests/fakedownloader.h0000644000015201777760000000225112306037363024165 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef FAKEDOWNLOADER_H #define FAKEDOWNLOADER_H #include namespace ClickPlugin { class FakeDownloader : public QObject { Q_OBJECT public: explicit FakeDownloader(QObject *parent = 0); void startDownload(QString packagename, QString url, const QString& authHeader); signals: void downloadCreated(QString packagename, QString dbuspath); void downloadNotCreated(QString packagename, QString error); }; } #endif // FAKEDOWNLOADER_H clickmanager-plugin-0.1+14.04.20140306/tests/fakedownloader.cpp0000644000015201777760000000223112306037363024516 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "fakedownloader.h" #include namespace ClickPlugin { FakeDownloader::FakeDownloader(QObject *parent) : QObject(parent) { } void FakeDownloader::startDownload(QString packagename, QString url, const QString& authHeader) { if(authHeader.isEmpty()) { emit this->downloadNotCreated(packagename, QString("DOWNLOAD ERROR")); } else { emit this->downloadCreated(packagename, "/com/canonical/download/path"); } } } clickmanager-plugin-0.1+14.04.20140306/tests/testclickmanager.cpp0000644000015201777760000000615312306037363025060 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "testclickmanager.h" #include "clickmanager.h" #include "application.h" namespace ClickPlugin { void TestClickManager::cleanup() { this->m_signal_counter = 0; } void TestClickManager::slotModelChanged() { this->m_signal_counter++; } void TestClickManager::testCheckUpdatesModelSignal() { this->m_signal_counter = 0; ClickManager manager; this->connect(&(manager), SIGNAL(modelChanged()), this, SLOT(slotModelChanged())); QCOMPARE(manager.m_apps.size(), 0); manager.checkUpdates(); QCOMPARE(manager.m_apps.size(), 4); QCOMPARE(manager.m_model.size(), 1); Application* app = manager.m_model[0].value(); QCOMPARE(app->getTitle(), QString("XDA Developers App")); QCOMPARE(app->updateRequired(), true); QCOMPARE(app->getPackageName(), QString("com.ubuntu.developer.xda-app")); QCOMPARE(this->m_signal_counter, 2); } void TestClickManager::testCheckUpdatesUpdateSignal() { this->m_signal_counter = 0; ClickManager manager; this->connect(&(manager), SIGNAL(updateAvailableFound()), this, SLOT(slotModelChanged())); QCOMPARE(manager.m_apps.size(), 0); manager.checkUpdates(); QCOMPARE(manager.m_apps.size(), 4); QCOMPARE(manager.m_model.size(), 1); Application* app = manager.m_model[0].value(); QCOMPARE(app->getTitle(), QString("XDA Developers App")); QCOMPARE(app->updateRequired(), true); QCOMPARE(app->getPackageName(), QString("com.ubuntu.developer.xda-app")); QCOMPARE(this->m_signal_counter, 1); } void TestClickManager::testStartDownload() { ClickManager manager; manager.checkUpdates(); Application* app = manager.m_model[0].value(); manager.startDownload(app->getPackageName()); QCOMPARE(app->updateState(), true); QCOMPARE(app->dbusPath(), QString("/com/canonical/download/path")); } void TestClickManager::testTokenObtained() { ClickManager manager; manager.checkUpdates(); QCOMPARE(manager.m_token.isValid(), true); } void TestClickManager::testDownloadNotCreated() { ClickManager manager; manager.checkUpdates(); manager.m_token = Token(); Application* app = manager.m_model[0].value(); manager.startDownload(app->getPackageName()); QCOMPARE(app->updateState(), false); QCOMPARE(app->dbusPath(), QString("")); QCOMPARE(app->getError(), QString("Invalid User Token")); } } clickmanager-plugin-0.1+14.04.20140306/tests/click.result0000644000015201777760000000134212306037363023354 0ustar pbusernogroup00000000000000[ { "framework": "ubuntu-sdk-13.10", "name": "com.ubuntu.dropping-letters", "title": "Dropping Letters game", "version": "0.1.2.2" }, { "framework": "ubuntu-sdk-13.10", "name": "com.ubuntu.stock-ticker-mobile", "title": "A stock trading app with charts, news, and management", "version": "0.3.7ubuntu1" }, { "framework": "ubuntu-sdk-13.10", "name": "com.ubuntu.sudoku", "title": "Sudoku game for Ubuntu devices", "version": "0.4.2ubuntu2" }, { "framework": "ubuntu-sdk-13.10", "name": "com.ubuntu.developer.xda-app", "title": "XDA Developers App", "version": "0.4.2ubuntu2" } ] clickmanager-plugin-0.1+14.04.20140306/clickmanager-plugin.pro0000644000015201777760000000005312306037363024321 0ustar pbusernogroup00000000000000TEMPLATE = subdirs SUBDIRS += src/ tests/ clickmanager-plugin-0.1+14.04.20140306/src/0000755000015201777760000000000012306037572020456 5ustar pbusernogroup00000000000000clickmanager-plugin-0.1+14.04.20140306/src/download/0000755000015201777760000000000012306037572022265 5ustar pbusernogroup00000000000000clickmanager-plugin-0.1+14.04.20140306/src/download/group_download_struct.cpp0000644000015201777760000000476312306037363027430 0ustar pbusernogroup00000000000000/* * copyright 2013 2013 canonical ltd. * * this library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the gnu lesser general public * license as published by the free software foundation. * * this 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 lesser general public * license along with this library; if not, write to the * free software foundation, inc., 51 franklin street, fifth floor, * boston, ma 02110-1301, usa. */ #include #include "./hash_algorithm.h" #include "./group_download_struct.h" GroupDownloadStruct::GroupDownloadStruct() : _url(""), _hash("") { } GroupDownloadStruct::GroupDownloadStruct(const QString& url, const QString& localFile, const QString& hash) : _url(url), _localFile(localFile), _hash(hash) { } GroupDownloadStruct::GroupDownloadStruct(const GroupDownloadStruct& other) : _url(other._url), _localFile(other._localFile), _hash(other._hash) { } GroupDownloadStruct& GroupDownloadStruct::operator=( const GroupDownloadStruct& other) { _url = other._url; _localFile = other._localFile; _hash = other._hash; return *this; } GroupDownloadStruct::~GroupDownloadStruct() { } QDBusArgument &operator<<(QDBusArgument& argument, const GroupDownloadStruct& group) { argument.beginStructure(); argument << group._url; argument << group._localFile; argument << group._hash; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument& argument, GroupDownloadStruct& group) { argument.beginStructure(); argument >> group._url; argument >> group._localFile; argument >> group._hash; argument.endStructure(); return argument; } void GroupDownloadStruct::registerMetaType() { qRegisterMetaType("GroupDownloadStruct"); qDBusRegisterMetaType(); } QString GroupDownloadStruct::getUrl() { return _url; } QString GroupDownloadStruct::getHash() { return _hash; } QString GroupDownloadStruct::getLocalFile() { return _localFile; } clickmanager-plugin-0.1+14.04.20140306/src/download/downloadmanager.cpp0000644000015201777760000000150412306037363026131 0ustar pbusernogroup00000000000000/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i download_struct.h -i group_download_struct.h -i metatypes.h com.canonical.applications.download_manager.xml * * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments * before re-generating it. */ #include "downloadmanager.h" /* * Implementation of interface class DownloadManager */ DownloadManager::DownloadManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } DownloadManager::~DownloadManager() { } clickmanager-plugin-0.1+14.04.20140306/src/download/group_download_struct.h0000644000015201777760000000350612306037363027067 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef GROUP_DOWNLOAD_STRUCT_H #define GROUP_DOWNLOAD_STRUCT_H #include class GroupDownloadStruct { Q_PROPERTY(QString url READ getUrl) Q_PROPERTY(QString hash READ getHash) Q_PROPERTY(QString localFile READ getLocalFile) public: GroupDownloadStruct(); GroupDownloadStruct(const QString& url, const QString& localFile, const QString& hash); GroupDownloadStruct(const GroupDownloadStruct& other); GroupDownloadStruct& operator=(const GroupDownloadStruct& other); ~GroupDownloadStruct(); friend QDBusArgument &operator<<(QDBusArgument &argument, const GroupDownloadStruct& group); friend const QDBusArgument &operator>>(const QDBusArgument &argument, GroupDownloadStruct& group); // register Secret with the Qt type system static void registerMetaType(); // property getters QString getUrl(); QString getHash(); QString getLocalFile(); private: QString _url; QString _localFile; QString _hash; }; typedef QList StructList; Q_DECLARE_METATYPE(GroupDownloadStruct) #endif //GROUP_DOWNLOAD_STRUCT_H clickmanager-plugin-0.1+14.04.20140306/src/download/metatypes.h0000644000015201777760000000164612306037363024456 0ustar pbusernogroup00000000000000/* * Copyright 2013 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef DOWNLOADER_LIB_APP_METATYPES_H #define DOWNLOADER_LIB_APP_METATYPES_H #include typedef QMap StringMap; Q_DECLARE_METATYPE(StringMap) #endif // DOWNLOADER_LIB_APP_METATYPES_H clickmanager-plugin-0.1+14.04.20140306/src/download/downloader.h0000644000015201777760000000241312306037363024572 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef DOWNLOADER_H #define DOWNLOADER_H #include #include #include #include "downloadmanager.h" namespace ClickPlugin { class Downloader : public QObject { Q_OBJECT public: explicit Downloader(QObject *parent = 0); void startDownload(QString packagename, const QString& url, const QString& authHeader); signals: void downloadCreated(QString packagename, QString dbuspath); void downloadNotCreated(QString packagename, QString error); private: DownloadManager* manager; }; } #endif // DOWNLOADER_H clickmanager-plugin-0.1+14.04.20140306/src/download/downloadtrackeradaptor.cpp0000644000015201777760000000151612306037363027530 0ustar pbusernogroup00000000000000/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -v -c DownloadTrackerAdaptor -p downloadtrackeradaptor.h:downloadtrackeradaptor.cpp -i metatypes.h com.canonical.applications.download.xml * * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments * before re-generating it. */ #include "downloadtrackeradaptor.h" /* * Implementation of interface class DownloadTrackerAdaptor */ DownloadTrackerAdaptor::DownloadTrackerAdaptor(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } DownloadTrackerAdaptor::~DownloadTrackerAdaptor() { } clickmanager-plugin-0.1+14.04.20140306/src/download/com.canonical.applications.download_manager.xml0000644000015201777760000000353112306037363033500 0ustar pbusernogroup00000000000000 clickmanager-plugin-0.1+14.04.20140306/src/download/com.canonical.applications.download.xml0000644000015201777760000000330712306037363032007 0ustar pbusernogroup00000000000000 clickmanager-plugin-0.1+14.04.20140306/src/download/downloader.cpp0000644000015201777760000000373412306037363025134 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "downloader.h" #include #include "metatypes.h" #include "network/network.h" #define DOWNLOAD_COMMAND "post-download-command" #define APP_ID "app_id" namespace ClickPlugin { Downloader::Downloader(QObject *parent) : QObject(parent) { qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); this->manager = new DownloadManager("com.canonical.applications.Downloader", "/", QDBusConnection::sessionBus(), 0); } void Downloader::startDownload(QString packagename, const QString& url, const QString& authHeader) { QVariantMap vmap; QStringList args; args << "pkcon" << "-p" << "install-local" << "$file"; vmap[DOWNLOAD_COMMAND] = args; vmap[APP_ID] = packagename; StringMap map; map[X_CLICK_TOKEN] = authHeader; DownloadStruct down = DownloadStruct(url, vmap, map); QDBusPendingReply reply = this->manager->createDownload(down); reply.waitForFinished(); if (reply.isError()) { emit this->downloadNotCreated(packagename, reply.error().message()); }else{ QDBusObjectPath path = reply.value(); emit this->downloadCreated(packagename, path.path()); } } } clickmanager-plugin-0.1+14.04.20140306/src/download/downloadtrackeradaptor.h0000644000015201777760000000725712306037363027205 0ustar pbusernogroup00000000000000/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -v -c DownloadTrackerAdaptor -p downloadtrackeradaptor.h:downloadtrackeradaptor.cpp -i metatypes.h com.canonical.applications.download.xml * * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ #ifndef DOWNLOADTRACKERADAPTOR_H_1377699393 #define DOWNLOADTRACKERADAPTOR_H_1377699393 #include #include #include #include #include #include #include #include #include "metatypes.h" /* * Proxy class for interface com.canonical.applications.Download */ class DownloadTrackerAdaptor: public QDBusAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.canonical.applications.Download"; } public: DownloadTrackerAdaptor(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~DownloadTrackerAdaptor(); public Q_SLOTS: // METHODS inline QDBusPendingReply<> allowGSMDownload(bool allowed) { QList argumentList; argumentList << QVariant::fromValue(allowed); return asyncCallWithArgumentList(QLatin1String("allowGSMDownload"), argumentList); } inline QDBusPendingReply<> cancel() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("cancel"), argumentList); } inline QDBusPendingReply isGSMDownloadAllowed() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("isGSMDownloadAllowed"), argumentList); } inline QDBusPendingReply metadata() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("metadata"), argumentList); } inline QDBusPendingReply<> pause() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("pause"), argumentList); } inline QDBusPendingReply progress() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("progress"), argumentList); } inline QDBusPendingReply<> resume() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("resume"), argumentList); } inline QDBusPendingReply<> setThrottle(qulonglong speed) { QList argumentList; argumentList << QVariant::fromValue(speed); return asyncCallWithArgumentList(QLatin1String("setThrottle"), argumentList); } inline QDBusPendingReply<> start() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("start"), argumentList); } inline QDBusPendingReply throttle() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("throttle"), argumentList); } inline QDBusPendingReply totalSize() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("totalSize"), argumentList); } Q_SIGNALS: // SIGNALS void canceled(bool success); void error(const QString &error); void finished(const QString &path); void paused(bool success); void progress(qulonglong received, qulonglong total); void resumed(bool success); void started(bool success); }; namespace com { namespace canonical { namespace applications { typedef ::DownloadTrackerAdaptor Download; } } } #endif clickmanager-plugin-0.1+14.04.20140306/src/download/download_struct.h0000644000015201777760000000436212306037363025654 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef DOWNLOAD_STRUCT_H #define DOWNLOAD_STRUCT_H #include #include #include #include typedef QMap StringList; class DownloadStruct { Q_PROPERTY(QString url READ getUrl) Q_PROPERTY(QString hash READ getHash) Q_PROPERTY(QString algorithm READ getAlgorithm) Q_PROPERTY(QVariantMap metadata READ getMetadata) Q_PROPERTY(StringList headers READ getHeaders) public: DownloadStruct(); DownloadStruct(const QString& url, const QVariantMap& metadata, const QMap& headers); DownloadStruct(const QString& url, const QString& hash, const QString& algorithm, const QVariantMap& metadata, const QMap& headers); DownloadStruct(const DownloadStruct& other); DownloadStruct& operator=(const DownloadStruct& other); ~DownloadStruct(); friend QDBusArgument &operator<<(QDBusArgument &argument, const DownloadStruct& download); friend const QDBusArgument &operator>>(const QDBusArgument &argument, DownloadStruct& download); // properties getters QString getUrl(); QString getHash(); QString getAlgorithm(); QVariantMap getMetadata(); QMap getHeaders(); private: QString _url; QString _hash; QString _algorithm; QVariantMap _metadata; QMap _headers; }; Q_DECLARE_METATYPE(DownloadStruct) #endif // DOWNLOAD_STRUCT_H clickmanager-plugin-0.1+14.04.20140306/src/download/downloadmanager.h0000644000015201777760000000727512306037363025611 0ustar pbusernogroup00000000000000/* * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i download_struct.h -i group_download_struct.h -i metatypes.h com.canonical.applications.download_manager.xml * * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ #ifndef DOWNLOADMANAGER_H_1378918266 #define DOWNLOADMANAGER_H_1378918266 #include #include #include #include #include #include #include #include #include "download_struct.h" #include "group_download_struct.h" #include "metatypes.h" /* * Proxy class for interface com.canonical.applications.DownloadManager */ class DownloadManager: public QDBusAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.canonical.applications.DownloadManager"; } public: DownloadManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~DownloadManager(); public Q_SLOTS: // METHODS inline QDBusPendingReply<> allowGSMDownload(bool allowed) { QList argumentList; argumentList << QVariant::fromValue(allowed); return asyncCallWithArgumentList(QLatin1String("allowGSMDownload"), argumentList); } inline QDBusPendingReply createDownload(DownloadStruct download) { QList argumentList; argumentList << QVariant::fromValue(download); return asyncCallWithArgumentList(QLatin1String("createDownload"), argumentList); } inline QDBusPendingReply createDownloadGroup(StructList downloads, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers) { QList argumentList; argumentList << QVariant::fromValue(downloads) << QVariant::fromValue(algorithm) << QVariant::fromValue(allowed3G) << QVariant::fromValue(metadata) << QVariant::fromValue(headers); return asyncCallWithArgumentList(QLatin1String("createDownloadGroup"), argumentList); } inline QDBusPendingReply defaultThrottle() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("defaultThrottle"), argumentList); } inline QDBusPendingReply > getAllDownloads() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("getAllDownloads"), argumentList); } inline QDBusPendingReply > getAllDownloadsWithMetadata(const QString &name, const QString &value) { QList argumentList; argumentList << QVariant::fromValue(name) << QVariant::fromValue(value); return asyncCallWithArgumentList(QLatin1String("getAllDownloadsWithMetadata"), argumentList); } inline QDBusPendingReply isGSMDownloadAllowed() { QList argumentList; return asyncCallWithArgumentList(QLatin1String("isGSMDownloadAllowed"), argumentList); } inline QDBusPendingReply<> setDefaultThrottle(qulonglong speed) { QList argumentList; argumentList << QVariant::fromValue(speed); return asyncCallWithArgumentList(QLatin1String("setDefaultThrottle"), argumentList); } Q_SIGNALS: // SIGNALS void downloadCreated(const QDBusObjectPath &path); }; namespace com { namespace canonical { namespace applications { typedef ::DownloadManager DownloadManager; } } } #endif clickmanager-plugin-0.1+14.04.20140306/src/download/download_struct.cpp0000644000015201777760000000576312306037363026215 0ustar pbusernogroup00000000000000/* * Copyright 2013 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "./download_struct.h" DownloadStruct::DownloadStruct() : _url(""), _hash(""), _algorithm(""), _metadata(), _headers() { } DownloadStruct::DownloadStruct(const QString& url, const QVariantMap& metadata, const QMap& headers) : _url(url), _hash(""), _algorithm(""), _metadata(metadata), _headers(headers) { } DownloadStruct::DownloadStruct(const QString& url, const QString& hash, const QString& algorithm, const QVariantMap& metadata, const QMap& headers) : _url(url), _hash(hash), _algorithm(algorithm), _metadata(metadata), _headers(headers) { } DownloadStruct::DownloadStruct(const DownloadStruct& other) : _url(other._url), _hash(other._hash), _algorithm(other._algorithm), _metadata(other._metadata), _headers(other._headers) { } DownloadStruct& DownloadStruct::operator=(const DownloadStruct& other) { _url = other._url; _hash = other._hash; _algorithm = other._algorithm; _metadata = other._metadata; _headers = other._headers; return *this; } DownloadStruct::~DownloadStruct() { } QDBusArgument &operator<<(QDBusArgument &argument, const DownloadStruct& download) { argument.beginStructure(); argument << download._url; argument << download._hash; argument << download._algorithm; argument << download._metadata; argument << download._headers; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, DownloadStruct& download) { argument.beginStructure(); argument >> download._url; argument >> download._hash; argument >> download._algorithm; argument >> download._metadata; argument >> download._headers; argument.endStructure(); return argument; } QString DownloadStruct::getUrl() { return _url; } QString DownloadStruct::getHash() { return _hash; } QString DownloadStruct::getAlgorithm() { return _algorithm; } QVariantMap DownloadStruct::getMetadata() { return _metadata; } QMap DownloadStruct::getHeaders() { return _headers; } clickmanager-plugin-0.1+14.04.20140306/src/download/hash_algorithm.cpp0000644000015201777760000000403612306037363025763 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "./hash_algorithm.h" QCryptographicHash::Algorithm HashAlgorithm::getHashAlgo(const QString& algorithm) { // lowercase the algorithm just in case QString algoLower = algorithm.toLower(); QCryptographicHash::Algorithm algo = QCryptographicHash::Md5; if (algoLower == "md5") algo = QCryptographicHash::Md5; else if (algoLower == "sha1") algo = QCryptographicHash::Sha1; else if (algoLower == "sha224") algo = QCryptographicHash::Sha224; else if (algoLower == "sha256") algo = QCryptographicHash::Sha256; else if (algoLower == "sha384") algo = QCryptographicHash::Sha384; else if (algoLower == "sha512") algo = QCryptographicHash::Sha512; else algo = QCryptographicHash::Md5; return algo; } QString HashAlgorithm::getHashAlgo(QCryptographicHash::Algorithm algorithm) { switch (algorithm) { case QCryptographicHash::Md5: return "md5"; case QCryptographicHash::Sha1: return "sha1"; case QCryptographicHash::Sha224: return "sha224"; case QCryptographicHash::Sha256: return "shq256"; case QCryptographicHash::Sha384: return "sha384"; case QCryptographicHash::Sha512: return "sha512"; default: return ""; } } clickmanager-plugin-0.1+14.04.20140306/src/download/hash_algorithm.h0000644000015201777760000000206712306037363025432 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef DOWNLOADER_LIB_HASH_ALGORITHM_H #define DOWNLOADER_LIB_HASH_ALGORITHM_H #include #include class HashAlgorithm { public: static QCryptographicHash::Algorithm getHashAlgo(const QString& algorithm); static QString getHashAlgo(QCryptographicHash::Algorithm algorithm); }; #endif // DOWNLOADER_LIB_HASH_ALGORITHM_H clickmanager-plugin-0.1+14.04.20140306/src/download_tracker.h0000644000015201777760000000370512306037363024154 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 Lesser General Public License, as * published by the Free Software Foundation; either version 2.1 or 3.0 * of the License. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License along with this program. If not, see * * Authored by: Diego Sarmentero */ #ifndef MYTYPE_H #define MYTYPE_H #include #include #include #include namespace ClickPlugin { class DownloadTracker : public QQuickItem { Q_OBJECT Q_DISABLE_COPY(DownloadTracker) Q_PROPERTY(QString service READ service WRITE setService) Q_PROPERTY(QString dbusPath READ dbusPath WRITE setDbusPath) Q_PROPERTY(bool serviceReady READ isServiceReady) public: DownloadTracker(QQuickItem *parent = 0); QString dbusPath() { return this->m_dbusPath; } QString service() { return this->m_service; } void setDbusPath(QString& path); void setService(QString& service); bool isServiceReady(); signals: void canceled(bool success); void error(const QString &error); void finished(const QString &path); void paused(bool success); void progress(qulonglong received, qulonglong total); void resumed(bool success); void started(bool success); private: QString m_dbusPath; QString m_service; DownloadTrackerAdaptor* adaptor; void startService(); }; } QML_DECLARE_TYPE(ClickPlugin::DownloadTracker) #endif // MYTYPE_H clickmanager-plugin-0.1+14.04.20140306/src/application.h0000644000015201777760000000740612306037363023137 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef APPLICATION_H #define APPLICATION_H #include #include namespace ClickPlugin { class Application : public QQuickItem { Q_OBJECT Q_DISABLE_COPY(Application) Q_PROPERTY(QString packageName READ getPackageName) Q_PROPERTY(QString title READ getTitle NOTIFY titleChanged) Q_PROPERTY(QString localVersion READ getLocalVersion NOTIFY localVersionChanged) Q_PROPERTY(QString remoteVersion READ getRemoteVersion NOTIFY remoteVersionChanged) Q_PROPERTY(QString toUpdate READ updateRequired) Q_PROPERTY(QString iconUrl READ iconUrl NOTIFY iconUrlChanged) Q_PROPERTY(int binaryFilesize READ binaryFilesize NOTIFY binaryFilesizeChanged) Q_PROPERTY(bool updateState READ updateState WRITE setUpdateState NOTIFY updatesStateChanged) Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged) Q_PROPERTY(QString dbusPath READ dbusPath NOTIFY dbusPathChanged) Q_PROPERTY(QString error READ getError NOTIFY errorChanged) signals: void titleChanged(); void binaryFilesizeChanged(); void iconUrlChanged(); void localVersionChanged(); void remoteVersionChanged(); void updatesStateChanged(); void selectedChanged(); void dbusPathChanged(); void errorChanged(); public: Application(QQuickItem *parent = 0); QString getPackageName() { return this->m_packagename; } QString getTitle() { return this->m_title; } QString getLocalVersion() { return this->m_local_version; } QString getRemoteVersion() { return this->m_remote_version; } QString dbusPath() { return this->m_dbuspath; } QString iconUrl() { return this->m_icon_url; } int binaryFilesize() { return this->m_binary_filesize; } bool updateRequired() { return this->m_update; } bool updateState() { return this->m_update_state; } bool selected() { return this->m_selected; } QString getError() { return this->m_error; } const QString& getClickUrl() const { return this->m_click_url; } void initializeApplication(QString packagename, QString title, QString version); void setRemoteVersion(QString& version); void setUpdateState(bool state) { this->m_update_state = state; emit this->updatesStateChanged(); } void setSelected(bool value) { this->m_selected = value; emit this->selectedChanged(); } void setDbusPath(QString dbuspath) { this->m_dbuspath = dbuspath; emit this->dbusPathChanged(); } void setBinaryFilesize(int size) { this->m_binary_filesize = size; emit this->binaryFilesizeChanged(); } void setIconUrl(QString icon) { this->m_icon_url = icon; emit this->iconUrlChanged(); } void setError(QString error); void setClickUrl(const QString& url) { this->m_click_url = url; } private: QString m_packagename; QString m_title; QString m_local_version; QString m_remote_version; QString m_dbuspath; QString m_icon_url; QString m_error; QString m_click_url; int m_binary_filesize; bool m_update; bool m_update_state; bool m_selected; }; } QML_DECLARE_TYPE(ClickPlugin::Application) #endif // APPLICATION_H clickmanager-plugin-0.1+14.04.20140306/src/download_tracker.cpp0000644000015201777760000000466612306037363024516 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 Lesser General Public License, as * published by the Free Software Foundation; either version 2.1 or 3.0 * of the License. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License along with this program. If not, see * * Authored by: Diego Sarmentero */ #include "download_tracker.h" #include namespace ClickPlugin { DownloadTracker::DownloadTracker(QQuickItem *parent) : QQuickItem(parent) { } bool DownloadTracker::isServiceReady() { bool ready = false; if(this->adaptor != NULL) { ready = this->adaptor->isValid(); } return ready; } void DownloadTracker::setDbusPath(QString& path) { if(path != ""){ this->m_dbusPath = path; this->startService(); } } void DownloadTracker::setService(QString& service) { if(service != ""){ this->m_service = service; this->startService(); } } void DownloadTracker::startService() { if(!this->m_service.isEmpty() && !this->m_dbusPath.isEmpty()) { qDebug() << "service:" << this->m_service << this->m_dbusPath; this->adaptor = new DownloadTrackerAdaptor(this->m_service, this->m_dbusPath, QDBusConnection::sessionBus(), 0); this->connect(this->adaptor, SIGNAL(canceled(bool)), this, SIGNAL(canceled(bool))); this->connect(this->adaptor, SIGNAL(error(const QString &)), this, SIGNAL(error(const QString &))); this->connect(this->adaptor, SIGNAL(finished(const QString &)), this, SIGNAL(finished(const QString &))); this->connect(this->adaptor, SIGNAL(paused(bool)), this, SIGNAL(paused(bool))); this->connect(this->adaptor, SIGNAL(progress(qulonglong, qulonglong)), this, SIGNAL(progress(qulonglong, qulonglong))); this->connect(this->adaptor, SIGNAL(resumed(bool)), this, SIGNAL(resumed(bool))); this->connect(this->adaptor, SIGNAL(started(bool)), this, SIGNAL(started(bool))); this->adaptor->start(); } } } clickmanager-plugin-0.1+14.04.20140306/src/application.cpp0000644000015201777760000000352212306037363023465 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "application.h" #include #include #include namespace ClickPlugin { Application::Application(QQuickItem *parent) : QQuickItem(parent) { this->m_packagename = ""; this->m_title = ""; this->m_local_version = ""; this->m_remote_version = ""; this->m_dbuspath = ""; this->m_update = false; this->m_update_state = false; this->m_selected = false; this->m_icon_url = ""; this->m_binary_filesize = 0; this->m_click_url = ""; } void Application::initializeApplication(QString packagename, QString title, QString version) { this->m_packagename = packagename; this->m_title = title; this->m_local_version = version; } void Application::setRemoteVersion(QString& version) { this->m_remote_version = version; int result = debVS.CmpVersion(this->m_local_version.toUtf8().data(), this->m_remote_version.toUtf8().data()); this->m_update = result < 0; } void Application::setError(QString error) { this->m_error = error; if(!this->m_error.isEmpty()) { emit this->errorChanged(); } } } clickmanager-plugin-0.1+14.04.20140306/src/clickmanager.h0000644000015201777760000000517512306037363023255 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef CLICKMANAGER_H #define CLICKMANAGER_H #include #include #include #include #include #include "application.h" #include #ifdef TESTS #include "fakeprocess.h" #include "fakenetwork.h" #include "fakedownloader.h" #include "testclickmanager.h" #include "fakessoservice.h" #else #include #include #include "network/network.h" #include "download/downloader.h" #endif using namespace UbuntuOne; namespace ClickPlugin { class ClickManager : public QQuickItem { Q_OBJECT Q_DISABLE_COPY(ClickManager) Q_PROPERTY(QVariantList model READ model NOTIFY modelChanged) #ifdef TESTS friend class TestClickManager; #endif signals: void modelChanged(); void updatesNotFound(); void credentialsNotFound(); void updateAvailableFound(); void errorFound(); public: ClickManager(QQuickItem *parent = 0); ~ClickManager(); Q_INVOKABLE void checkUpdates(); Q_INVOKABLE void startDownload(QString packagename); QVariantList model() const { return this->m_model; } private slots: void processOutput(); void processUpdates(); void downloadUrlObtained(QString packagename, QString url); void downloadCreated(QString packagename, QString dbuspath); void downloadNotCreated(QString packagename, QString error); void handleCredentialsFound(Token token); void handleCredentialsNotFound(); void clickTokenReceived(Application* app, const QString& clickToken); private: QHash m_apps; QVariantList m_model; Token m_token; #ifdef TESTS FakeSsoService m_service; FakeNetwork m_network; FakeDownloader downloader; FakeProcess m_process; #else SSOService m_service; QProcess m_process; Network m_network; Downloader downloader; #endif void checkForUpdates(); }; } QML_DECLARE_TYPE(ClickPlugin::ClickManager) #endif // CLICKMANAGER_H clickmanager-plugin-0.1+14.04.20140306/src/clickmanager_plugin.cpp0000644000015201777760000000221212306037363025153 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "clickmanager_plugin.h" #include "clickmanager.h" #include "application.h" #include "download_tracker.h" #include using namespace ClickPlugin; void ClickManagerPlugin::registerTypes(const char *uri) { // @uri com.ubuntu.click qmlRegisterType(uri, 0, 1, "ClickManager"); qmlRegisterType(uri, 0, 1, "Application"); qmlRegisterType(uri, 0, 1, "DownloadTracker"); } clickmanager-plugin-0.1+14.04.20140306/src/clickmanager_plugin.h0000644000015201777760000000202012306037363024615 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef CLICKMANAGER_PLUGIN_H #define CLICKMANAGER_PLUGIN_H #include class ClickManagerPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: void registerTypes(const char *uri); }; #endif // CLICKMANAGER_PLUGIN_H clickmanager-plugin-0.1+14.04.20140306/src/network/0000755000015201777760000000000012306037572022147 5ustar pbusernogroup00000000000000clickmanager-plugin-0.1+14.04.20140306/src/network/network.cpp0000644000015201777760000001132212306037363024341 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "network.h" #include #include #include #include #include #include #include #define URL_APPS "https://myapps.developer.ubuntu.com/dev/api/click-metadata/" #define URL_PACKAGE "https://search.apps.ubuntu.com/api/v1/package/" namespace ClickPlugin { Network::Network(QObject *parent) : QObject(parent) { this->_nam = new QNetworkAccessManager(this); this->_request = new QNetworkRequest(); this->_request->setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); QObject::connect(this->_nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(onReply(QNetworkReply*))); } void Network::checkForNewVersions(QHash &apps) { this->_apps = apps; QJsonObject serializer; QJsonArray array; foreach(QString id, this->_apps.keys()) { array.append(QJsonValue(this->_apps.value(id)->getPackageName())); } serializer.insert("name", array); QJsonDocument doc(serializer); QByteArray content = doc.toJson(); this->_request->setUrl(QUrl(URL_APPS)); this->_nam->post(*this->_request, content); } void Network::onReply(QNetworkReply* reply) { QVariant statusAttr = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute); if (!statusAttr.isValid()) { emit this->errorOccurred(); return; } int httpStatus = statusAttr.toInt(); qDebug() << "Network::OnReply from " << reply->url() << " status: " << httpStatus; if (httpStatus == 200 || httpStatus == 201) { if (reply->hasRawHeader(X_CLICK_TOKEN)) { Application* app = qobject_cast(reply->request().originatingObject()); if(app != NULL) { QString header(reply->rawHeader(X_CLICK_TOKEN)); emit this->clickTokenObtained(app, header); } reply->deleteLater(); return; } QByteArray payload = reply->readAll(); QJsonDocument document = QJsonDocument::fromJson(payload); reply->deleteLater(); if (document.isArray()) { QJsonArray array = document.array(); int i; bool updates = false; for(i = 0; i < array.size(); i++) { QJsonObject object = array.at(i).toObject(); QString name = object.value("name").toString(); QString version = object.value("version").toString(); QString icon_url = object.value("icon_url").toString(); int size = object.value("binary_filesize").toVariant().toInt(); if(this->_apps.contains(name)) { this->_apps[name]->setRemoteVersion(version); this->_apps[name]->setIconUrl(icon_url); this->_apps[name]->setBinaryFilesize(size); if(this->_apps[name]->updateRequired()) { updates = true; } } } if(updates) { emit this->updatesFound(); }else{ emit this->updatesNotFound(); } } else if (document.isObject()){ QJsonObject object = document.object(); QString url = object.value("download_url").toString(); QString name = object.value("name").toString(); emit this->downloadUrlFound(name, url); } else { emit errorOccurred(); } } else { emit errorOccurred(); } } void Network::getResourceUrl(const QString& packagename) { this->_request->setUrl(QUrl(URL_PACKAGE + packagename)); this->_nam->get(*this->_request); } void Network::getClickToken(Application* app, const QString& url, const QString& authHeader) { QUrl query(url); query.setQuery(authHeader); QNetworkRequest request; request.setUrl(query); request.setOriginatingObject(app); this->_nam->head(request); } } clickmanager-plugin-0.1+14.04.20140306/src/network/network.h0000644000015201777760000000321712306037363024012 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef NETWORK_H #define NETWORK_H #include #include #include #include #include "application.h" #define X_CLICK_TOKEN "X-Click-Token" namespace ClickPlugin { class Network : public QObject { Q_OBJECT public: explicit Network(QObject *parent = 0); void checkForNewVersions(QHash &apps); void getResourceUrl(const QString& packagename); void getClickToken(Application* app, const QString& url, const QString& authHeader); signals: void updatesFound(); void updatesNotFound(); void errorOccurred(); void downloadUrlFound(QString packagename, QString url); void clickTokenObtained(Application* app, const QString& clickToken); private slots: void onReply(QNetworkReply*); private: QNetworkAccessManager* _nam; QNetworkRequest* _request; QHash _apps; }; } #endif // NETWORK_H clickmanager-plugin-0.1+14.04.20140306/src/clickmanager.cpp0000644000015201777760000001216412306037363023604 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This 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 Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "clickmanager.h" #include #include #include #include #include #include #include namespace ClickPlugin { ClickManager::ClickManager(QQuickItem *parent): QQuickItem(parent) , m_process(this) { QObject::connect(&m_service, SIGNAL(credentialsFound(const Token&)), this, SLOT(handleCredentialsFound(Token))); QObject::connect(&m_service, SIGNAL(credentialsNotFound()), this, SLOT(handleCredentialsNotFound())); QObject::connect(&(this->m_process), SIGNAL(finished(int)), this, SLOT(processOutput())); QObject::connect(&(this->m_network), SIGNAL(updatesFound()), this, SLOT(processUpdates())); QObject::connect(&(this->m_network), SIGNAL(updatesNotFound()), this, SIGNAL(updatesNotFound())); QObject::connect(&(this->m_network), SIGNAL(errorOccurred()), this, SIGNAL(errorFound())); QObject::connect(&(this->m_network), SIGNAL(clickTokenObtained(Application*, const QString&)), this, SLOT(clickTokenReceived(Application*,const QString&))); QObject::connect(&(this->m_network), SIGNAL(downloadUrlFound(QString,QString)), this, SLOT(downloadUrlObtained(QString,QString))); QObject::connect(&(this->downloader), SIGNAL(downloadCreated(QString,QString)), this, SLOT(downloadCreated(QString,QString))); QObject::connect(&(this->downloader), SIGNAL(downloadNotCreated(QString,QString)), this, SLOT(downloadNotCreated(QString,QString))); } ClickManager::~ClickManager() { } void ClickManager::handleCredentialsFound(Token token) { qDebug() << "Credentials found."; this->m_token = token; QStringList args("list"); args << "--manifest"; this->m_process.start("click", args); } void ClickManager::handleCredentialsNotFound() { qDebug() << "No credentials were found."; emit this->credentialsNotFound(); } void ClickManager::checkUpdates() { this->m_model.clear(); emit this->modelChanged(); this->m_service.getCredentials(); } void ClickManager::processOutput() { QString output(this->m_process.readAllStandardOutput()); QJsonDocument document = QJsonDocument::fromJson(output.toUtf8()); QJsonArray array = document.array(); int i; for(i = 0; i < array.size(); i++) { QJsonObject object = array.at(i).toObject(); QString name = object.value("name").toString(); QString title = object.value("title").toString(); QString version = object.value("version").toString(); Application* app = new Application(); app->initializeApplication(name, title, version); this->m_apps[app->getPackageName()] = app; } this->m_network.checkForNewVersions(this->m_apps); } void ClickManager::processUpdates() { foreach(QString id, this->m_apps.keys()) { Application* app = this->m_apps.value(id); if(app->updateRequired()) { this->m_model.append(QVariant::fromValue(app)); } } emit this->modelChanged(); emit this->updateAvailableFound(); } void ClickManager::startDownload(QString packagename) { qDebug() << "Download Package:" << packagename; this->m_network.getResourceUrl(packagename); } void ClickManager::downloadUrlObtained(QString packagename, QString url) { if(this->m_token.isValid()) { QString authHeader = this->m_token.signUrl(url, QStringLiteral("HEAD"), true); qDebug() << "Download Url:" << url; Application* app = this->m_apps[packagename]; app->setClickUrl(url); this->m_network.getClickToken(app, url, authHeader); } else { Application* app = this->m_apps[packagename]; app->setError("Invalid User Token"); } } void ClickManager::downloadCreated(QString packagename, QString dbuspath) { qDebug() << "Dbus Path:" << dbuspath; this->m_apps[packagename]->setDbusPath(dbuspath); this->m_apps[packagename]->setUpdateState(true); } void ClickManager::downloadNotCreated(QString packagename, QString error) { qDebug() << "Download not creeated"; Application* app = this->m_apps[packagename]; app->setError(error); } void ClickManager::clickTokenReceived(Application* app, const QString& clickToken) { app->setError(""); this->downloader.startDownload(app->getPackageName(), app->getClickUrl(), clickToken); } } clickmanager-plugin-0.1+14.04.20140306/src/qmldir0000644000015201777760000000005512306037363021667 0ustar pbusernogroup00000000000000module com.ubuntu.click plugin ClickManager clickmanager-plugin-0.1+14.04.20140306/src/src.pro0000644000015201777760000000313512306037363021767 0ustar pbusernogroup00000000000000TEMPLATE = lib TARGET = ClickManager QT += qml quick core dbus xml network CONFIG += qt plugin TARGET = $$qtLibraryTarget($$TARGET) uri = com.ubuntu.click # Input SOURCES += \ clickmanager_plugin.cpp \ clickmanager.cpp \ network/network.cpp \ application.cpp \ download/downloader.cpp \ download/downloadmanager.cpp \ download/downloadtrackeradaptor.cpp \ download_tracker.cpp \ download/download_struct.cpp \ download/group_download_struct.cpp \ download/hash_algorithm.cpp HEADERS += \ clickmanager_plugin.h \ clickmanager.h \ network/network.h \ application.h \ download/downloader.h \ download/downloadmanager.h \ download/metatypes.h \ download/downloadtrackeradaptor.h \ download_tracker.h \ download/download_struct.h \ download/group_download_struct.h \ download/hash_algorithm.h OTHER_FILES = qmldir !equals(_PRO_FILE_PWD_, $$OUT_PWD) { copy_qmldir.target = $$OUT_PWD/qmldir copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" QMAKE_EXTRA_TARGETS += copy_qmldir PRE_TARGETDEPS += $$copy_qmldir.target } qmldir.files = qmldir unix { installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) qmldir.path = $$installPath target.path = $$installPath INSTALLS += target qmldir } QMAKE_CXXFLAGS += -I /usr/include/ubuntuoneauth-2.0 -I /usr/include/signon-qt5 -I /usr/include/accounts-qt5 LIBS += -lapt-pkg -lubuntuoneauth-2.0 -lsignon-qt5 -laccounts-qt5 clickmanager-plugin-0.1+14.04.20140306/COPYING0000644000015201777760000001674312306037363020733 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.