./0000755000015600001650000000000012701152050011066 5ustar jenkinsjenkins./tests/0000755000015600001650000000000012701152050012230 5ustar jenkinsjenkins./tests/tests.pro0000644000015600001650000000015612701152050014116 0ustar jenkinsjenkinsTEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ unit CONFIG(medium-tests) { SUBDIRS += functional } ./tests/.config/0000755000015600001650000000000012701152050013553 5ustar jenkinsjenkins./tests/.config/signon-ui/0000755000015600001650000000000012701152050015463 5ustar jenkinsjenkins./tests/.config/signon-ui/webkit-options.d/0000755000015600001650000000000012701152050020663 5ustar jenkinsjenkins./tests/.config/signon-ui/webkit-options.d/localhost.conf0000644000015600001650000000016212701152050023521 0ustar jenkinsjenkinsUsernameField = input[name="username"] PasswordField = input[name="password"] LoginButton = input[type="submit"] ./tests/functional/0000755000015600001650000000000012701152050014372 5ustar jenkinsjenkins./tests/functional/reauthenticator.py0000755000015600001650000002135212701152050020153 0ustar jenkinsjenkins#! /usr/bin/python3 import unittest import logging import sys import dbus, dbus.service from dbus.mainloop.glib import DBusGMainLoop from gi.repository import Accounts from gi.repository import GLib from gi.repository import GObject SIGNOND_BUS_NAME = 'com.google.code.AccountsSSO.SingleSignOn' AUTH_SERVICE_IFACE = SIGNOND_BUS_NAME + '.AuthService' AUTH_SESSION_IFACE = SIGNOND_BUS_NAME + '.AuthSession' class MockAuthSession(dbus.service.Object): last_session = 0 def __init__(self, connection, identity, method): self.identity = identity self.method = method MockAuthSession.last_session += 1 path = '/session/{}'.format(MockAuthSession.last_session) super().__init__(connection, path) @dbus.service.method(dbus_interface=AUTH_SESSION_IFACE, in_signature='a{sv}s', out_signature='a{sv}') def process(self, session_data, mechanism): # Store the session data and mechanism, so that later they can be # verified by the test functions self.session_data = session_data self.mechanism = mechanism # signon-ui does not care what dictionary is returned, as long as it's # not an error; so let's just return the same dictionary return session_data class MockSignond(dbus.service.Object): def __init__(self, bus_name): super().__init__(bus_name, '/com/google/code/AccountsSSO/SingleSignOn') self.sessions = {} @dbus.service.method(dbus_interface=AUTH_SERVICE_IFACE, in_signature='u', out_signature='oa{sv}') def getIdentity(self, identity): return ('/identity/{}'.format(identity), {}) @dbus.service.method(dbus_interface=AUTH_SERVICE_IFACE, in_signature='us', out_signature='s') def getAuthSessionObjectPath(self, identity, method): session = MockAuthSession(self.connection, identity, method) self.sessions[session._object_path] = session return session._object_path class AuthenticatorTests(unittest.TestCase): credentials_id = 45000 @classmethod def setUpClass(cls): manager = Accounts.Manager() account = manager.create_account("any provider") account.set_enabled(True) v_credentials_id = GObject.Value() v_credentials_id.init(GObject.TYPE_UINT) v_credentials_id.set_uint(AuthenticatorTests.credentials_id) account.set_value('CredentialsId', v_credentials_id) account.store_blocking() AuthenticatorTests.account_id = account.id # Get a proxy for signon-ui bus = dbus.SessionBus() signon_ui_proxy = bus.get_object('com.nokia.singlesignonui', '/SignonUi') signon_ui = dbus.Interface(signon_ui_proxy, 'com.nokia.singlesignonui') webcredentials_proxy = bus.get_object('com.canonical.indicators.webcredentials', '/com/canonical/indicators/webcredentials') webcredentials = dbus.Interface(webcredentials_proxy, 'com.canonical.indicators.webcredentials') AuthenticatorTests.signon_ui = signon_ui AuthenticatorTests.webcredentials = webcredentials signond_bus_name = dbus.service.BusName(SIGNOND_BUS_NAME, bus=dbus.SessionBus()) AuthenticatorTests.signond_bus_name = signond_bus_name def setUp(self): self.test_failed = False self.signond = MockSignond(AuthenticatorTests.signond_bus_name) self.loop = GLib.MainLoop() def tearDown(self): self.signond.remove_from_connection() self.signond = None self.loop = None def failed_test(self, e): print(e) self.test_failed = True self.loop.quit() def test01_single_failure(self): log = logging.getLogger('AuthenticatorTests') self.method = 'TheMethod' self.mechanism = 'TheMechanism' client_data = dbus.Dictionary({ 'OneKey': 'OneValue', 'AnotherKey': 'AnotherValue' }, signature='sv') params = { 'OpenUrl': 'https://localhost/dontopen', 'Identity': self.credentials_id, 'Method': self.method, 'Mechanism': self.mechanism, 'ClientData': client_data, } reply = AuthenticatorTests.signon_ui.queryDialog(params) log.debug('Got reply: %s' % (reply,)) self.assertIn('QueryErrorCode', reply) self.assertEqual(reply['QueryErrorCode'], 10) def reauthenticate_cb(success): try: self.assertTrue(success) except: self.test_failed = True self.loop.quit() extra_data = dbus.Dictionary({ 'ExtraKey': 'ExtraValue', }, signature='sv') log.debug('Account id: ', self.account_id) AuthenticatorTests.webcredentials.ReauthenticateAccount(self.account_id, extra_data, reply_handler=reauthenticate_cb, error_handler=self.failed_test) self.loop.run() self.assertFalse(self.test_failed) # Now verify that the authentication data is consistent self.assertEqual(len(self.signond.sessions), 1) session = list(self.signond.sessions.values())[0] self.assertEqual(session.method, self.method) self.assertEqual(session.mechanism, self.mechanism) full_data = client_data.copy() full_data.update(extra_data) self.assertEqual(session.session_data, full_data) AuthenticatorTests.webcredentials.ReauthenticateAccount(self.account_id, extra_data, reply_handler=reauthenticate_cb, error_handler=self.failed_test) self.loop.run() def test02_many_failures(self): log = logging.getLogger('AuthenticatorTests') num_sessions = 8 sessions = {} def query_dialog_cb(reply): log.debug('Got reply: %s (count = %s)' % (reply, query_dialog_cb.call_count)) try: self.assertIn('QueryErrorCode', reply) self.assertEqual(reply['QueryErrorCode'], 10) except: self.test_failed = True query_dialog_cb.call_count += 1 if query_dialog_cb.call_count == num_sessions: self.loop.quit() query_dialog_cb.call_count = 0 for i in range(num_sessions): client_data = dbus.Dictionary({ 'OneKey': 'OneValue', 'AnotherKey': i }, signature='sv') params = { 'OpenUrl': 'https://localhost/dontopen', 'Identity': self.credentials_id, 'Method': 'method{}'.format(int(i / 2)), 'Mechanism': 'mechanism{}'.format(int(i / 3)), 'ClientData': client_data, } reply = AuthenticatorTests.signon_ui.queryDialog(params, reply_handler=query_dialog_cb, error_handler=self.failed_test) sessions[i] = params self.loop.run() self.assertFalse(self.test_failed) def reauthenticate_cb(success): log.debug('reauthenticate_cb: {}'.format(success)) try: self.assertTrue(success) except: self.test_failed = True self.loop.quit() extra_data = dbus.Dictionary({ 'ExtraKey': 'ExtraValue', }, signature='sv') AuthenticatorTests.webcredentials.ReauthenticateAccount(self.account_id, extra_data, reply_handler=reauthenticate_cb, error_handler=self.failed_test) self.loop.run() self.assertFalse(self.test_failed) # Now verify that the authentication data is consistent self.assertEqual(len(self.signond.sessions), num_sessions) actual_sessions = [] for session in self.signond.sessions.values(): s = { 'Method': session.method, 'Mechanism': session.mechanism, 'SessionData': session.session_data } actual_sessions.append(s) for session in sessions.values(): full_data = session['ClientData'].copy() full_data.update(extra_data) s = { 'Method': session['Method'], 'Mechanism': session['Mechanism'], 'SessionData': full_data } found = False for actual in actual_sessions: if s == actual: found = True break self.assertTrue(found) if __name__ == '__main__': DBusGMainLoop(set_as_default=True) logging.basicConfig(stream=sys.stderr) logging.getLogger('AuthenticatorTests').setLevel(logging.DEBUG) unittest.main(failfast=True, buffer=False, verbosity=2) ./tests/functional/run-with-signon-ui.sh0000755000015600001650000000026312701152050020415 0ustar jenkinsjenkins#! /bin/sh set -e export ACCOUNTS="/tmp" # start a local signon-ui dbus-test-runner -m 180 \ -t ${SRCDIR}/tests/functional/signon-ui.sh \ -t "$@" -f com.nokia.singlesignonui ./tests/functional/functional.pro0000644000015600001650000000044112701152050017255 0ustar jenkinsjenkinsinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) include($${TOP_SRC_DIR}/common-installs-config.pri) TEMPLATE = subdirs check.commands = "BUILDDIR=$$TOP_BUILD_DIR SRCDIR=$$TOP_SRC_DIR $$TOP_SRC_DIR/tests/functional/tests.sh" QMAKE_EXTRA_TARGETS += check ./tests/functional/signon-ui.sh0000755000015600001650000000013412701152050016637 0ustar jenkinsjenkins#! /bin/sh set -e export SSOUI_LOGGING_LEVEL=2 ${SSOUI_WRAPPER} ${BUILDDIR}/src/signon-ui ./tests/functional/tests.sh0000755000015600001650000000040712701152050016074 0ustar jenkinsjenkins#! /bin/sh if test -z "$DISPLAY" ; then echo "No X11 display; skipping functional tests" exit 0 fi export LC_ALL=C export HOME="$SRCDIR/tests/functional" export SSOUI_DAEMON_TIMEOUT=10 "$SRCDIR/tests/functional/run-with-signon-ui.sh" \ ./reauthenticator.py ./tests/unit/0000755000015600001650000000000012701152050013207 5ustar jenkinsjenkins./tests/unit/test.h0000644000015600001650000000233412701152050014341 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_TEST_H #define SIGNON_UI_TEST_H #include #include #include class SignOnUiTest: public QObject { Q_OBJECT public: SignOnUiTest(); private Q_SLOTS: void initTestCase(); void testRequestObjects(); void testRequestWithIndicator(); void testReauthenticator(); void testIndicatorService(); private: QDBusConnection m_dbusConnection; QDBusMessage m_dbusMessage; }; #endif // SIGNON_UI_TEST_H ./tests/unit/fake-libnotify.h0000644000015600001650000000166312701152050016271 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_FAKE_LIBNOTIFY #define SIGNON_UI_FAKE_LIBNOTIFY namespace FakeLibNotify { int notificationCount(); void clearNotificationCount(); }; #endif // SIGNON_UI_FAKE_LIBNOTIFY ./tests/unit/unit.pro0000644000015600001650000000012412701152050014705 0ustar jenkinsjenkinsTEMPLATE = subdirs SUBDIRS = \ tst_inactivity_timer.pro \ tst_signon_ui.pro ./tests/unit/fake-libsignon.cpp0000644000015600001650000000534612701152050016613 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include #include #include #include using namespace SignOn; namespace SignOn { class IdentityImpl { AuthSessionP createSession(const QString &method); friend class Identity; Identity *q; quint32 id; }; class AuthSessionImpl: public QObject { Q_OBJECT private Q_SLOTS: void emitResponse(); private: friend class AuthSession; AuthSession *q; quint32 id; QString method; SessionData sessionData; }; } // namespace AuthSessionP IdentityImpl::createSession(const QString &method) { /* pretend to fail creating a few authsessions */ if (id % 5 == 0) return 0; return new AuthSession(id, method, q); } Identity::Identity(quint32 id, QObject *parent): QObject(parent), impl(new IdentityImpl) { impl->id = id; impl->q = this; } Identity::~Identity() { delete impl; } Identity *Identity::existingIdentity(quint32 id, QObject *parent) { /* Pretend not to find a few identities */ if (id % 3 == 0) return 0; return new Identity(id, parent); } AuthSessionP Identity::createSession(const QString &method) { return impl->createSession(method); } void AuthSessionImpl::emitResponse() { Q_EMIT q->response(sessionData); } AuthSession::AuthSession(quint32 id, const QString &method, QObject *parent): QObject(parent), impl(new AuthSessionImpl) { qDebug() << "Created fake Authsession" << id << method; impl->q = this; impl->id = id; impl->method = method; } AuthSession::~AuthSession() { delete impl; } void AuthSession::process(const SessionData &sessionData, const QString &mechanism) { QVariantMap map = sessionData.toMap(); map["TheMechanism"] = mechanism; impl->sessionData = SessionData(map); /* delay the response with some pseudo-random wait */ int msec = 100 + (impl->id % 4) * 5; QTimer::singleShot(msec, impl, SLOT(emitResponse())); } #include "fake-libsignon.moc" ./tests/unit/test.cpp0000644000015600001650000002111712701152050014674 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "fake-libnotify.h" #include "indicator-service.h" #include "test.h" #include "reauthenticator.h" #include "request.h" #include "fake-webcredentials-interface.h" #include #include #include #include #include #include using namespace SignOnUi; SignOnUiTest::SignOnUiTest(): m_dbusConnection("test") { setLoggingLevel(2); } void SignOnUiTest::initTestCase() { /* Use a temporary DB for accounts */ setenv("ACCOUNTS", "/tmp/", false); QDir dbroot("/tmp"); dbroot.remove("accounts.db"); } void SignOnUiTest::testRequestObjects() { const WId windowId = 23141; const QString requestId = QLatin1String("request id 12342"); const QString title = QLatin1String("Title for the signon-ui window"); QVariantMap clientData; clientData[SSOUI_KEY_WINDOWID] = (uint)windowId; clientData[SSOUI_KEY_EMBEDDED] = true; QVariantMap parameters; parameters[SSOUI_KEY_REQUESTID] = requestId; parameters[SSOUI_KEY_TITLE] = title; parameters[SSOUI_KEY_QUERYPASSWORD] = true; parameters[SSOUI_KEY_CLIENT_DATA] = clientData; Request *request = Request::newRequest(m_dbusConnection, m_dbusMessage, parameters, this); QVERIFY(request != 0); QCOMPARE(request->parent(), this); QCOMPARE(request->id(), requestId); QCOMPARE(request->windowId(), windowId); QCOMPARE(request->embeddedUi(), true); QCOMPARE(request->parameters(), parameters); QCOMPARE(request->clientData(), clientData); QCOMPARE(request->isInProgress(), false); /* make sure that the request is of type DialogRequest */ QCOMPARE(request->metaObject()->className(), "SignOnUi::DialogRequest"); delete request; /* Now slightly modify the request parameters, so that a BrowserRequest * will be created instead */ parameters[SSOUI_KEY_OPENURL] = "http://localhost:9999/page404.html"; request = Request::newRequest(m_dbusConnection, m_dbusMessage, parameters, this); QVERIFY(request != 0); QCOMPARE(request->metaObject()->className(), "SignOnUi::BrowserRequest"); delete request; } void SignOnUiTest::testRequestWithIndicator() { const uint signonId = 1234; const QString displayName = QLatin1String("Beautiful account"); /* create an account claiming to use our fake signon-id */ Accounts::Manager *manager = new Accounts::Manager(this); /* first, create a couple of dummy accounts */ Accounts::Account *account = manager->createAccount(0); account->setEnabled(true); account->syncAndBlock(); account = manager->createAccount(0); account->setValue("CredentialsId", 0xdeadbeef); account->setEnabled(true); account->syncAndBlock(); /* now create the "good" account */ account = manager->createAccount(0); account->setValue("CredentialsId", signonId); account->setEnabled(true); account->setDisplayName(displayName); account->syncAndBlock(); /* now create a request */ QVariantMap parameters; parameters[SSOUI_KEY_QUERYPASSWORD] = true; parameters[SSOUI_KEY_IDENTITY] = signonId; Request *request = Request::newRequest(m_dbusConnection, m_dbusMessage, parameters, this); QVERIFY(request != 0); QCOMPARE(request->isInProgress(), false); QSignalSpy requestCompleted(request, SIGNAL(completed())); request->start(); QCOMPARE(requestCompleted.count(), 1); ComCanonicalIndicatorsWebcredentialsInterface *indicator = ComCanonicalIndicatorsWebcredentialsInterface::instance(); QVERIFY(indicator != 0); QCOMPARE(indicator->m_reportFailureCalled, true); QCOMPARE(indicator->m_account_id, account->id()); QCOMPARE(indicator->m_notification["DisplayName"].toString(), displayName); delete request; delete manager; } static void prepareAuthData(AuthData &authData, int identity) { QVariantMap sessionData; sessionData["Int"] = identity; authData.identity = identity; authData.sessionData = sessionData; authData.method = QString::fromLatin1("method%1").arg(identity); authData.mechanism = QString::fromLatin1("mechanism%1").arg(identity); } void SignOnUiTest::testReauthenticator() { QList failuresData; for (int i = 1; i < 8; i++) { AuthData authData; prepareAuthData(authData, i); failuresData.append(authData); } QVariantMap extraParameters; extraParameters["Greeting"] = QString::fromLatin1("Hello!"); Reauthenticator *reauthenticator = new Reauthenticator(failuresData, extraParameters); QSignalSpy finished(reauthenticator, SIGNAL(finished(bool))); reauthenticator->start(); QTest::qWait(200); QCOMPARE(finished.count(), 1); QList arguments = finished.takeFirst(); // first signal /* The reauthentication failed because of some invalid identities * created by the fake libsignon.*/ QCOMPARE(arguments.at(0).toBool(), false); delete reauthenticator; /* Now create the AuthData for the identities which are known to work */ failuresData.clear(); AuthData authData; prepareAuthData(authData, 1); failuresData.append(authData); prepareAuthData(authData, 2); failuresData.append(authData); prepareAuthData(authData, 4); failuresData.append(authData); reauthenticator = new Reauthenticator(failuresData, extraParameters); QSignalSpy finished2(reauthenticator, SIGNAL(finished(bool))); reauthenticator->start(); QTest::qWait(200); QCOMPARE(finished2.count(), 1); arguments = finished2.takeFirst(); // first signal QCOMPARE(arguments.at(0).toBool(), true); delete reauthenticator; } void SignOnUiTest::testIndicatorService() { const uint firstFailure = 413; QVERIFY(IndicatorService::instance() == 0); IndicatorService *service = new IndicatorService(); QVERIFY(service != 0); QCOMPARE(IndicatorService::instance(), service); QVERIFY(service->serviceObject() != 0); // Check initial status QVERIFY(service->failures().isEmpty()); QCOMPARE(service->errorStatus(), false); // Report the first failure service->reportFailure(firstFailure, QVariantMap()); QCOMPARE(FakeLibNotify::notificationCount(), 1); QCOMPARE(service->errorStatus(), true); QCOMPARE(service->failures().count(), 1); QVERIFY(service->failures().contains(firstFailure)); // Report more failures QList moreFailures; moreFailures << 89 << 412 << 1 << 4 << 144; foreach (uint id, moreFailures) { service->reportFailure(id, QVariantMap()); } QCOMPARE(FakeLibNotify::notificationCount(), 1); QCOMPARE(service->errorStatus(), true); QCOMPARE(service->failures().count(), 1 + moreFailures.count()); // Remove some failures QSet removedFailures; removedFailures << 4 << firstFailure << 89; service->removeFailures(removedFailures); QSet remainingFailures; remainingFailures << 412 << 1 << 144; QCOMPARE(FakeLibNotify::notificationCount(), 1); QCOMPARE(service->errorStatus(), true); QCOMPARE(service->failures(), remainingFailures); // Clear the error status service->clearErrorStatus(); QCOMPARE(service->errorStatus(), false); QCOMPARE(service->failures(), remainingFailures); // Send one more failure service->reportFailure(3, QVariantMap()); QCOMPARE(FakeLibNotify::notificationCount(), 2); QCOMPARE(service->errorStatus(), true); delete service; QVERIFY(IndicatorService::instance() == 0); } QTEST_MAIN(SignOnUiTest); ./tests/unit/tst_signon_ui.pro0000644000015600001650000000430412701152050016616 0ustar jenkinsjenkinsinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) TARGET = signon-ui-unittest CONFIG += \ build_all \ debug \ link_pkgconfig \ qtestlib QT += \ core \ dbus \ gui \ network \ webkit PKGCONFIG += \ signon-plugins-common \ libnotify lessThan(QT_MAJOR_VERSION, 5) { PKGCONFIG += \ accounts-qt \ libsignon-qt } else { QT += \ webkitwidgets \ widgets PKGCONFIG += \ accounts-qt5 \ libsignon-qt5 } SOURCES += \ fake-libnotify.cpp \ fake-libsignon.cpp \ fake-webcredentials-interface.cpp \ test.cpp \ $$TOP_SRC_DIR/src/animation-label.cpp \ $$TOP_SRC_DIR/src/browser-request.cpp \ $$TOP_SRC_DIR/src/cookie-jar-manager.cpp \ $$TOP_SRC_DIR/src/debug.cpp \ $$TOP_SRC_DIR/src/dialog-request.cpp \ $$TOP_SRC_DIR/src/dialog.cpp \ $$TOP_SRC_DIR/src/http-warning.cpp \ $$TOP_SRC_DIR/src/i18n.cpp \ $$TOP_SRC_DIR/src/indicator-service.cpp \ $$TOP_SRC_DIR/src/network-access-manager.cpp \ $$TOP_SRC_DIR/src/reauthenticator.cpp \ $$TOP_SRC_DIR/src/request.cpp \ $$TOP_SRC_DIR/src/webcredentials_adaptor.cpp HEADERS += \ fake-libnotify.h \ fake-webcredentials-interface.h \ test.h \ $$TOP_SRC_DIR/src/animation-label.h \ $$TOP_SRC_DIR/src/browser-request.h \ $$TOP_SRC_DIR/src/debug.h \ $$TOP_SRC_DIR/src/cookie-jar-manager.h \ $$TOP_SRC_DIR/src/dialog-request.h \ $$TOP_SRC_DIR/src/dialog.h \ $$TOP_SRC_DIR/src/http-warning.h \ $$TOP_SRC_DIR/src/indicator-service.h \ $$TOP_SRC_DIR/src/network-access-manager.h \ $$TOP_SRC_DIR/src/reauthenticator.h \ $$TOP_SRC_DIR/src/request.h \ $$TOP_SRC_DIR/src/webcredentials_adaptor.h lessThan(QT_MAJOR_VERSION, 5) { SOURCES += $$TOP_SRC_DIR/src/embed-manager.cpp HEADERS += $$TOP_SRC_DIR/src/embed-manager.h } INCLUDEPATH += \ . \ $$TOP_SRC_DIR/src QMAKE_CXXFLAGS += \ -fno-exceptions \ -fno-rtti DEFINES += \ DEBUG_ENABLED \ UNIT_TESTS RESOURCES += $$TOP_SRC_DIR/src/animationlabel.qrc check.depends = $${TARGET} check.commands = "xvfb-run -a dbus-test-runner -t ./signon-ui-unittest" QMAKE_EXTRA_TARGETS += check ./tests/unit/fake-webcredentials-interface.cpp0000644000015600001650000000347712701152050021563 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "fake-webcredentials-interface.h" #include static ComCanonicalIndicatorsWebcredentialsInterface *m_instance = 0; ComCanonicalIndicatorsWebcredentialsInterface:: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent): QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent), m_reportFailureCalled(false), m_account_id(0) { qDebug() << "ComCanonicalIndicatorsWebcredentialsInterface instantiated"; m_instance = this; QDBusMessage message; setReply(QDBusPendingCall::fromCompletedCall(message.createReply())); } ComCanonicalIndicatorsWebcredentialsInterface:: ~ComCanonicalIndicatorsWebcredentialsInterface() { m_instance = 0; } ComCanonicalIndicatorsWebcredentialsInterface * ComCanonicalIndicatorsWebcredentialsInterface::instance() { return m_instance; } ./tests/unit/tst_inactivity_timer.cpp0000644000015600001650000000632712701152050020200 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "inactivity-timer.h" #include #include #include #include using namespace SignOnUi; class InactivityTest: public QObject { Q_OBJECT public: InactivityTest() {}; private Q_SLOTS: void testAlwaysIdle(); void testIdleThenBusy(); void testStartBusy(); }; class TestObject: public QObject { Q_OBJECT Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) public: TestObject(): QObject(0), m_isIdle(false) {} ~TestObject() {} bool isIdle() const { return m_isIdle; } void setIdle(bool idle) { if (idle == m_isIdle) return; m_isIdle = idle; Q_EMIT isIdleChanged(); } Q_SIGNALS: void isIdleChanged(); private: bool m_isIdle; }; void InactivityTest::testAlwaysIdle() { InactivityTimer inactivityTimer(100); QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout())); TestObject object1; object1.setIdle(true); inactivityTimer.watchObject(&object1); TestObject object2; object2.setIdle(true); inactivityTimer.watchObject(&object2); QCOMPARE(timeout.count(), 0); QTest::qWait(150); QCOMPARE(timeout.count(), 1); } void InactivityTest::testIdleThenBusy() { InactivityTimer inactivityTimer(100); QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout())); TestObject object1; object1.setIdle(true); inactivityTimer.watchObject(&object1); TestObject object2; object2.setIdle(true); inactivityTimer.watchObject(&object2); QCOMPARE(timeout.count(), 0); QTest::qWait(30); QCOMPARE(timeout.count(), 0); object2.setIdle(false); QTest::qWait(100); QCOMPARE(timeout.count(), 0); object2.setIdle(true); QTest::qWait(30); QCOMPARE(timeout.count(), 0); QTest::qWait(100); QCOMPARE(timeout.count(), 1); } void InactivityTest::testStartBusy() { InactivityTimer inactivityTimer(100); QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout())); TestObject object1; inactivityTimer.watchObject(&object1); TestObject object2; inactivityTimer.watchObject(&object2); QCOMPARE(timeout.count(), 0); QTest::qWait(130); QCOMPARE(timeout.count(), 0); object2.setIdle(true); QTest::qWait(130); QCOMPARE(timeout.count(), 0); object1.setIdle(true); QTest::qWait(30); QCOMPARE(timeout.count(), 0); QTest::qWait(100); QCOMPARE(timeout.count(), 1); } QTEST_MAIN(InactivityTest); #include "tst_inactivity_timer.moc" ./tests/unit/tst_inactivity_timer.pro0000644000015600001650000000120412701152050020203 0ustar jenkinsjenkinsinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) TARGET = tst_inactivity_timer CONFIG += \ build_all \ debug \ qtestlib QT += \ core SOURCES += \ tst_inactivity_timer.cpp \ $$TOP_SRC_DIR/src/debug.cpp \ $$TOP_SRC_DIR/src/inactivity-timer.cpp HEADERS += \ $$TOP_SRC_DIR/src/debug.h \ $$TOP_SRC_DIR/src/inactivity-timer.h INCLUDEPATH += \ . \ $$TOP_SRC_DIR/src QMAKE_CXXFLAGS += \ -fno-exceptions \ -fno-rtti DEFINES += \ DEBUG_ENABLED \ UNIT_TESTS check.commands = "xvfb-run -a ./$$TARGET" check.depends = $$TARGET QMAKE_EXTRA_TARGETS += check ./tests/unit/fake-libnotify.cpp0000644000015600001650000000335312701152050016622 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "fake-libnotify.h" #undef signals #include #include static int m_notificationCount = 0; static NotifyNotification *fake_notification = 0; int FakeLibNotify::notificationCount() { return m_notificationCount; } void FakeLibNotify::clearNotificationCount() { m_notificationCount = 0; } gboolean notify_init(const char *app_name) { g_return_val_if_fail(app_name != NULL, FALSE); return TRUE; } NotifyNotification *notify_notification_new(const char *, const char *, const char *) { fake_notification = (NotifyNotification *)g_object_new (G_TYPE_OBJECT, NULL); return fake_notification; } gboolean notify_notification_show(NotifyNotification *notification, GError **error) { g_return_val_if_fail(notification == fake_notification, FALSE); *error = NULL; m_notificationCount++; return TRUE; } ./tests/unit/fake-webcredentials-interface.h0000644000015600001650000000526012701152050021220 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #define SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #include #include #include #include #include #include #include #include /* * Fake proxy class for interface com.canonical.indicators.webcredentials, * for unit testing. */ class ComCanonicalIndicatorsWebcredentialsInterface: public QDBusAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.canonical.indicators.webcredentials"; } public: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~ComCanonicalIndicatorsWebcredentialsInterface(); public Q_SLOTS: // METHODS QDBusPendingReply<> RemoveFailures() { return m_reply; } QDBusPendingReply<> ReportFailure(uint account_id, const QVariantMap ¬ification) { qDebug() << "Report failure called"; m_reportFailureCalled = true; m_account_id = account_id; m_notification = notification; return m_reply; } private: void setReply(const QDBusPendingCall &reply) { m_reply = static_cast >(reply); } static ComCanonicalIndicatorsWebcredentialsInterface *instance(); friend class SignOnUiTest; QDBusPendingReply<> m_reply; bool m_reportFailureCalled; uint m_account_id; QVariantMap m_notification; }; namespace com { namespace canonical { namespace indicators { typedef ::ComCanonicalIndicatorsWebcredentialsInterface webcredentials; } } } #endif // SIGNON_UI_WEBCREDENTIALS_INTERFACE_H ./common-vars.pri0000644000015600001650000000140512701152050014043 0ustar jenkinsjenkins#----------------------------------------------------------------------------- # Common variables for all projects. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Project name (used e.g. in include file and doc install path). # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_NAME = signon-ui #----------------------------------------------------------------------------- # Project version # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_VERSION = 0.15 # End of File ./src/0000755000015600001650000000000012701152055011662 5ustar jenkinsjenkins./src/network-access-manager.h0000644000015600001650000000227112701152050016370 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_NETWORK_ACCESS_MANAGER_H #define SIGNON_UI_NETWORK_ACCESS_MANAGER_H #include #include namespace SignOnUi { class NetworkAccessManager: public QNetworkAccessManager { Q_OBJECT public: ~NetworkAccessManager(); static NetworkAccessManager *instance(); protected: explicit NetworkAccessManager(QObject *parent = 0); }; } // namespace #endif // SIGNON_UI_NETWORK_ACCESS_MANAGER_H ./src/my-network-proxy-factory.h0000644000015600001650000000215112701152050016765 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_MY_NETWORK_PROXY_FACTORY_H #define SIGNON_UI_MY_NETWORK_PROXY_FACTORY_H #include class MyNetworkProxyFactory: public QNetworkProxyFactory { public: // reimplemented virtual methods QList queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()); }; #endif // SIGNON_UI_MY_NETWORK_PROXY_FACTORY_H ./src/dialog.h0000644000015600001650000000216612701152050013272 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DIALOG_H #define SIGNON_UI_DIALOG_H #include #include namespace SignOnUi { class Dialog: public QDialog { Q_OBJECT public: explicit Dialog(QWidget *parent = 0, Qt::WindowFlags f = 0); ~Dialog(); protected: // reimplemented virtual methods void closeEvent(QCloseEvent *e); }; } // namespace #endif // SIGNON_UI_DIALOG_H ./src/signonui_dbus_adaptor.pri0000644000015600001650000000425312701152050016757 0ustar jenkinsjenkins# This script is a modified copy of Qt's mkspecs/features/dbusadaptors.prf, # written to allow passing extra "-i" options to qdbusxml2cpp qtPrepareTool(QMAKE_QDBUSXML2CPP, qdbusxml2cpp) for(SIGNONUI_DBUS_ADAPTOR, $$list($$unique(SIGNONUI_DBUS_ADAPTORS))) { !contains(SIGNONUI_DBUS_ADAPTOR, .*\\w\\.xml$) { warning("Invalid D-BUS adaptor: '$${DBUS_ADAPTOR}', please use 'com.mydomain.myinterface.xml' instead.") next() } SIGNONUI_DBUS_ADAPTOR_LIST += $${SIGNONUI_DBUS_ADAPTOR} } for(SIGNONUI_DBUS_INCLUDE, $$list($$unique(SIGNONUI_DBUS_INCLUDES))) { QDBUS_EXTRA_OPTIONS += -i $${SIGNONUI_DBUS_INCLUDE} } signonui_dbus_adaptor_header.commands = $$QMAKE_QDBUSXML2CPP -a ${QMAKE_FILE_OUT}: ${QMAKE_FILE_IN} signonui_dbus_adaptor_header.output_function = signonui_dbus_adaptor_header_output signonui_dbus_adaptor_header.name = DBUSXML2CPP ADAPTOR HEADER ${QMAKE_FILE_IN} signonui_dbus_adaptor_header.variable_out = SIGNONUI_DBUS_ADAPTOR_HEADERS signonui_dbus_adaptor_header.input = SIGNONUI_DBUS_ADAPTOR_LIST defineReplace(signonui_dbus_adaptor_header_output) { return("$$lower($$section($$list($$basename(1)),.,-2,-2))_adaptor.h") } signonui_dbus_adaptor_source.commands = $$QMAKE_QDBUSXML2CPP $$QDBUS_EXTRA_OPTIONS -i ${QMAKE_FILE_OUT_BASE}.h -a :${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} signonui_dbus_adaptor_source.output_function = signonui_dbus_adaptor_source_output signonui_dbus_adaptor_source.name = DBUSXML2CPP ADAPTOR SOURCE ${QMAKE_FILE_IN} signonui_dbus_adaptor_source.variable_out = SOURCES signonui_dbus_adaptor_source.input = SIGNONUI_DBUS_ADAPTOR_LIST load(moc) signonui_dbus_adaptor_moc.commands = $$moc_header.commands signonui_dbus_adaptor_moc.output = $$moc_header.output signonui_dbus_adaptor_moc.depends = $$signonui_dbus_adaptor_header.output signonui_dbus_adaptor_moc.input = SIGNONUI_DBUS_ADAPTOR_HEADERS signonui_dbus_adaptor_moc.variable_out = GENERATED_SOURCES signonui_dbus_adaptor_moc.name = $$moc_header.name defineReplace(signonui_dbus_adaptor_source_output) { return("$$lower($$section($$list($$basename(1)),.,-2,-2))_adaptor.cpp") } QMAKE_EXTRA_COMPILERS += signonui_dbus_adaptor_header signonui_dbus_adaptor_source signonui_dbus_adaptor_moc ./src/network-access-manager.cpp0000644000015600001650000000262412701152050016725 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "network-access-manager.h" #include "debug.h" using namespace SignOnUi; static NetworkAccessManager *m_instance = 0; /* At the moment the only reason for using this class is reusing the NAM across * network requests. * We might want to add here proxy settings, or specialized cookie jars * integrated with the user's desktop browser. */ NetworkAccessManager::NetworkAccessManager(QObject *parent): QNetworkAccessManager(parent) { } NetworkAccessManager::~NetworkAccessManager() { } NetworkAccessManager *NetworkAccessManager::instance() { if (m_instance == 0) { m_instance = new NetworkAccessManager(); } return m_instance; } ./src/request.cpp0000644000015600001650000002745112701152055014067 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define HAS_XEMBED (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \ defined(FORCE_FOREIGN_QWINDOW)) #include "request.h" #ifdef USE_UBUNTU_WEB_VIEW #include "ubuntu-browser-request.h" #endif #include "browser-request.h" #include "debug.h" #include "dialog-request.h" #if HAS_XEMBED #include "embed-manager.h" #endif #include "errors.h" #include "indicator-service.h" #ifndef UNIT_TESTS #include "webcredentials_interface.h" #else #include "fake-webcredentials-interface.h" #endif #include #include #include #include #include #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #include #include #endif #if HAS_FOREIGN_QWINDOW #include #endif #include #include using namespace SignOnUi; using namespace com::canonical; namespace SignOnUi { class RequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(Request) public: RequestPrivate(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, Request *request); ~RequestPrivate(); WId windowId() const { return m_clientData[SSOUI_KEY_WINDOWID].toUInt(); } bool embeddedUi() const { return m_clientData[SSOUI_KEY_EMBEDDED].toBool(); } private Q_SLOTS: #if HAS_XEMBED void onEmbedError(); #endif void onIndicatorCallFinished(QDBusPendingCallWatcher *watcher); private: void setWidget(QWidget *widget); Accounts::Account *findAccount(); bool dispatchToIndicator(); void onIndicatorCallSucceeded(); private: mutable Request *q_ptr; QDBusConnection m_connection; QDBusMessage m_message; QVariantMap m_parameters; QVariantMap m_clientData; bool m_inProgress; Accounts::Manager *m_accountManager; QPointer m_widget; }; } // namespace RequestPrivate::RequestPrivate(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, Request *request): QObject(request), q_ptr(request), m_connection(connection), m_message(message), m_parameters(parameters), m_inProgress(false), m_accountManager(0), m_widget(0) { if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) { QVariant variant = parameters[SSOUI_KEY_CLIENT_DATA]; m_clientData = (variant.type() == QVariant::Map) ? variant.toMap() : qdbus_cast(variant.value()); } } RequestPrivate::~RequestPrivate() { } void RequestPrivate::setWidget(QWidget *widget) { if (m_widget != 0) { BLAME() << "Widget already set"; return; } m_widget = widget; #if HAS_XEMBED if (embeddedUi() && windowId() != 0) { TRACE() << "Requesting widget embedding"; QX11EmbedWidget *embed = EmbedManager::instance()->widgetFor(windowId()); QObject::connect(embed, SIGNAL(error(QX11EmbedWidget::Error)), this, SLOT(onEmbedError()), Qt::UniqueConnection); QObject::connect(embed, SIGNAL(containerClosed()), widget, SLOT(close())); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(widget); widget->show(); /* Delete any previous layout */ delete embed->layout(); embed->setLayout(layout); embed->show(); return; } #endif #if HAS_FOREIGN_QWINDOW if (embeddedUi() && windowId() != 0) { TRACE() << "Requesting window embedding"; QWindow *host = QWindow::fromWinId(windowId()); widget->show(); widget->windowHandle()->setParent(host); return; } #endif /* If the window has no parent and the webcredentials indicator service is * up, dispatch the request to it. */ if (windowId() == 0 && dispatchToIndicator()) { return; } widget->setWindowModality(Qt::WindowModal); widget->show(); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) if (windowId() != 0) { TRACE() << "Setting" << widget->effectiveWinId() << "transient for" << windowId(); XSetTransientForHint(QX11Info::display(), widget->effectiveWinId(), windowId()); } #endif #if HAS_FOREIGN_QWINDOW if (windowId() != 0) { TRACE() << "Requesting window reparenting"; QWindow *parent = QWindow::fromWinId(windowId()); widget->windowHandle()->setTransientParent(parent); } #endif } #if HAS_XEMBED void RequestPrivate::onEmbedError() { Q_Q(Request); QX11EmbedWidget *embed = qobject_cast(sender()); TRACE() << "Embed error:" << embed->error(); q->fail(SIGNON_UI_ERROR_EMBEDDING_FAILED, QString("Embedding signon UI failed: %1").arg(embed->error())); } #endif Accounts::Account *RequestPrivate::findAccount() { if (!m_parameters.contains(SSOUI_KEY_IDENTITY)) return 0; uint identity = m_parameters.value(SSOUI_KEY_IDENTITY).toUInt(); if (identity == 0) return 0; /* Find the account using this identity. * FIXME: there might be more than one! */ if (m_accountManager == 0) { m_accountManager = new Accounts::Manager(this); } foreach (Accounts::AccountId accountId, m_accountManager->accountList()) { Accounts::Account *account = m_accountManager->account(accountId); if (account == 0) continue; QVariant value(QVariant::UInt); if (account->value("CredentialsId", value) != Accounts::NONE && value.toUInt() == identity) { return account; } } // Not found return 0; } bool RequestPrivate::dispatchToIndicator() { Q_Q(Request); Accounts::Account *account = findAccount(); if (account == 0) { return false; } QVariantMap notification; notification["DisplayName"] = account->displayName(); notification["ClientData"] = m_clientData; notification["Identity"] = q->identity(); notification["Method"] = q->method(); notification["Mechanism"] = q->mechanism(); indicators::webcredentials *webcredentialsIf = new indicators::webcredentials(WEBCREDENTIALS_BUS_NAME, WEBCREDENTIALS_OBJECT_PATH, m_connection, this); QDBusPendingReply<> reply = webcredentialsIf->ReportFailure(account->id(), notification); if (reply.isFinished()) { if (reply.isError() && /* if this is a fake D-Bus interface, we get the * "Disconnected" error. */ reply.error().type() != QDBusError::Disconnected) { BLAME() << "Error dispatching to indicator:" << reply.error().message(); return false; } else { onIndicatorCallSucceeded(); return true; } } QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onIndicatorCallFinished(QDBusPendingCallWatcher*))); return true; } void RequestPrivate::onIndicatorCallFinished(QDBusPendingCallWatcher *watcher) { if (watcher->isError()) { /* if the notification could not be delivered to the indicator, show * the widget. */ if (m_widget != 0) m_widget->show(); } else { onIndicatorCallSucceeded(); } } void RequestPrivate::onIndicatorCallSucceeded() { Q_Q(Request); /* the account has been reported as failing. We can now close this * request, and tell the application that UI interaction is forbidden. */ QVariantMap result; result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_FORBIDDEN; q->setResult(result); } Request *Request::newRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent) { if (parameters.contains(SSOUI_KEY_OPENURL)) { #ifdef USE_UBUNTU_WEB_VIEW TRACE() << "Platform:" << QGuiApplication::platformName(); if (QGuiApplication::platformName().startsWith("ubuntu") || qgetenv("XDG_CURRENT_DESKTOP") == QByteArray("Unity") || qgetenv("SSOUI_USE_UBUNTU_WEB_VIEW") == QByteArray("1")) { return new UbuntuBrowserRequest(connection, message, parameters, parent); } #endif return new BrowserRequest(connection, message, parameters, parent); } else { return new DialogRequest(connection, message, parameters, parent); } } Request::Request(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): QObject(parent), d_ptr(new RequestPrivate(connection, message, parameters, this)) { } Request::~Request() { } QString Request::id(const QVariantMap ¶meters) { return parameters[SSOUI_KEY_REQUESTID].toString(); } QString Request::id() const { Q_D(const Request); return Request::id(d->m_parameters); } void Request::setWidget(QWidget *widget) { Q_D(Request); d->setWidget(widget); } uint Request::identity() const { Q_D(const Request); return d->m_parameters.value(SSOUI_KEY_IDENTITY).toUInt(); } QString Request::method() const { Q_D(const Request); return d->m_parameters.value(SSOUI_KEY_METHOD).toString(); } QString Request::mechanism() const { Q_D(const Request); return d->m_parameters.value(SSOUI_KEY_MECHANISM).toString(); } WId Request::windowId() const { Q_D(const Request); return d->windowId(); } bool Request::embeddedUi() const { Q_D(const Request); return d->embeddedUi(); } bool Request::isInProgress() const { Q_D(const Request); return d->m_inProgress; } const QVariantMap &Request::parameters() const { Q_D(const Request); return d->m_parameters; } const QVariantMap &Request::clientData() const { Q_D(const Request); return d->m_clientData; } void Request::start() { Q_D(Request); if (d->m_inProgress) { BLAME() << "Request already started!"; return; } d->m_inProgress = true; } void Request::cancel() { setCanceled(); } void Request::fail(const QString &name, const QString &message) { Q_D(Request); QDBusMessage reply = d->m_message.createErrorReply(name, message); d->m_connection.send(reply); Q_EMIT completed(); } void Request::setCanceled() { QVariantMap result; result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_CANCELED; setResult(result); } void Request::setResult(const QVariantMap &result) { Q_D(Request); QDBusMessage reply = d->m_message.createReply(result); d->m_connection.send(reply); Q_EMIT completed(); } #include "request.moc" ./src/dialog.cpp0000644000015600001650000000176712701152050013633 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "dialog.h" #include "debug.h" using namespace SignOnUi; Dialog::Dialog(QWidget *parent, Qt::WindowFlags f): QDialog(parent, f) { } Dialog::~Dialog() { } void Dialog::closeEvent(QCloseEvent *e) { reject(); QDialog::closeEvent(e); } ./src/qquick-dialog.cpp0000644000015600001650000000345412701152055015126 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \ defined(FORCE_FOREIGN_QWINDOW)) #include "qquick-dialog.h" #include "debug.h" #include using namespace SignOnUi::QQuick; Dialog::Dialog(QWindow *parent): QQuickView(parent) { setResizeMode(QQuickView::SizeRootObjectToView); } Dialog::~Dialog() { } void Dialog::show(WId parent, ShowMode mode) { create(); #if HAS_FOREIGN_QWINDOW if (mode != TopLevel) { QWindow *parentWindow = QWindow::fromWinId(parent); if (mode == Transient) { setTransientParent(parentWindow); } else if (mode == Embedded) { setParent(parentWindow); } } #endif QQuickView::show(); } void Dialog::accept() { done(Dialog::Accepted); } void Dialog::reject() { done(Dialog::Rejected); } void Dialog::done(int result) { setVisible(false); Q_EMIT finished(result); } bool Dialog::event(QEvent *e) { if (e->type() == QEvent::Close) { reject(); } return QQuickView::event(e); } ./src/animation-label.cpp0000644000015600001650000000343512701152050015422 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (c) 2009 Nokia Corporation * Copyright (C) 2012 Canonical Ltd. * * Contact: David King * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "animation-label.h" AnimationLabel::AnimationLabel(const QString &animationPath, QWidget *parent): QWidget(parent) { m_animation = new QMovie(animationPath, QByteArray(), this); // We need a container for the QMovie. QLabel *container = new QLabel(this); container->setMovie(m_animation); QVBoxLayout *layout = new QVBoxLayout(this); layout->setAlignment(Qt::AlignCenter); layout->setSpacing(0); layout->setMargin(0); layout->addWidget(container); setLayout(layout); } AnimationLabel::~AnimationLabel() { } void AnimationLabel::start() { // Let's check if the movie can be started. if (m_animation->state() == QMovie::NotRunning || m_animation->state() == QMovie::Paused) { // It can so start the animation. m_animation->start(); } } void AnimationLabel::stop() { // Check if the animation can be stopped. if (m_animation->state() == QMovie::Running) { // It can so stop the animation. m_animation->stop(); } } ./src/cookie-jar-manager.h0000644000015600001650000000410312701152050015457 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_COOKIE_JAR_MANAGER_H #define SIGNON_UI_COOKIE_JAR_MANAGER_H #include #include #include #include #include namespace SignOnUi { typedef QMap RawCookies; class CookieJar: public QNetworkCookieJar { Q_OBJECT public: CookieJar(QString cookiePath, QObject *parent = 0); ~CookieJar() {} QList cookiesForUrl(const QUrl &url) const; bool setCookiesFromUrl(const QList &cookieList, const QUrl &url); void setCookies(const QList &cookieList) { queueSave(); setAllCookies(cookieList); } public Q_SLOTS: void save(); private: void queueSave(); private: QString m_cookiePath; QTimer m_saveTimer; }; class CookieJarManagerPrivate; class CookieJarManager: public QObject { Q_OBJECT public: ~CookieJarManager(); static CookieJarManager *instance(); CookieJar *cookieJarForIdentity(uint id); void removeForIdentity(uint id); public Q_SLOTS: void saveAll(); protected: explicit CookieJarManager(QObject *parent = 0); private: CookieJarManagerPrivate *d_ptr; Q_DECLARE_PRIVATE(CookieJarManager) }; } // namespace Q_DECLARE_METATYPE(SignOnUi::RawCookies) #endif // SIGNON_UI_COOKIE_JAR_MANAGER_H ./src/animationlabel.qrc0000644000015600001650000000013612701152050015343 0ustar jenkinsjenkins spinner-26.gif ./src/remote-request-interface.h0000644000015600001650000000365012701152050016751 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_REMOTE_REQUEST_INTERFACE_H #define SIGNON_UI_REMOTE_REQUEST_INTERFACE_H #include #include namespace SignOnUi { class RemoteRequestClientPrivate; class RemoteRequestClient: public QObject { Q_OBJECT public: RemoteRequestClient(QObject *parent = 0); ~RemoteRequestClient(); void setChannels(QIODevice *readChannel, QIODevice *writeChannel); void start(const QVariantMap ¶meters); void cancel(); Q_SIGNALS: void result(const QVariantMap &result); void canceled(); private: RemoteRequestClientPrivate *d_ptr; Q_DECLARE_PRIVATE(RemoteRequestClient) }; class RemoteRequestServerPrivate; class RemoteRequestServer: public QObject { Q_OBJECT public: RemoteRequestServer(QObject *parent = 0); ~RemoteRequestServer(); void setChannels(QIODevice *readChannel, QIODevice *writeChannel); void setResult(const QVariantMap &result); void setCanceled(); Q_SIGNALS: void started(const QVariantMap ¶meters); void canceled(); private: RemoteRequestServerPrivate *d_ptr; Q_DECLARE_PRIVATE(RemoteRequestServer) }; } // namespace #endif // SIGNON_UI_REMOTE_REQUEST_INTERFACE_H ./src/inactivity-timer.h0000644000015600001650000000255012701152050015331 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_INACTIVITY_TIMER_H #define SIGNON_UI_INACTIVITY_TIMER_H #include #include #include namespace SignOnUi { class InactivityTimer: public QObject { Q_OBJECT public: InactivityTimer(int interval, QObject *parent = 0); ~InactivityTimer() {} void watchObject(QObject *object); Q_SIGNALS: void timeout(); private Q_SLOTS: void onIdleChanged(); void onTimeout(); private: bool allObjectsAreIdle() const; private: QList m_watchedObjects; QTimer m_timer; int m_interval; }; } // namespace #endif // SIGNON_UI_INACTIVITY_TIMER_H ./src/animation-label.h0000644000015600001650000000235012701152050015062 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (c) 2009 Nokia Corporation * Copyright (C) 2012 Canonical Ltd. * * Contact: David King * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef ANIMATIONLABEL_H_ #define ANIMATIONLABEL_H_ #include #include #include /** * AnimationLabel * * Uses animation from the path to display it in a QLabel. */ class AnimationLabel : public QWidget { Q_OBJECT public: AnimationLabel(const QString &animationPath, QWidget *parent); virtual ~AnimationLabel(); public Q_SLOTS: void start(); void stop(); private: QMovie *m_animation; }; #endif /* ANIMATIONLABEL_H_ */ ./src/cookie-jar-manager.cpp0000644000015600001650000001225012701152050016014 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) #include "cookie-jar-manager.h" #include "debug.h" #include #include #include #include #include #include #include #include using namespace SignOnUi; static CookieJarManager *m_instance = 0; static const unsigned int JAR_VERSION = 1; namespace SignOnUi { QList CookieJar::cookiesForUrl(const QUrl &url) const { return QNetworkCookieJar::cookiesForUrl(url); } bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url) { TRACE() << "Setting cookies for url:" << url; TRACE() << cookieList; queueSave(); return QNetworkCookieJar::setCookiesFromUrl(cookieList, url); } class CookieJarManagerPrivate { Q_DECLARE_PUBLIC(CookieJarManager) private: mutable CookieJarManager *q_ptr; QHash cookieJars; QDir cookieDir; }; } // namespace QDataStream &operator<<(QDataStream &stream, const QList &list) { stream << JAR_VERSION; stream << quint32(list.size()); foreach (const QNetworkCookie &cookie, list) { stream << cookie.toRawForm(); } return stream; } QDataStream &operator>>(QDataStream &stream, QList &list) { list.clear(); quint32 version; stream >> version; if (version != JAR_VERSION) return stream; quint32 count; stream >> count; for (quint32 i = 0; i < count; i++) { QByteArray value; stream >> value; QList newCookies = QNetworkCookie::parseCookies(value); if (newCookies.count() == 0 && value.length() != 0) { qWarning() << "CookieJar: Unable to parse saved cookie:" << value; } foreach (const QNetworkCookie &cookie, newCookies) { list.append(cookie); } if (stream.atEnd()) break; } return stream; } CookieJar::CookieJar(QString cookiePath, QObject *parent): QNetworkCookieJar(parent), m_cookiePath(cookiePath) { // Prepare the auto-save timer m_saveTimer.setInterval(10 * 1000); m_saveTimer.setSingleShot(true); QObject::connect(&m_saveTimer, SIGNAL(timeout()), this, SLOT(save())); // Load any saved cookies QFile file(m_cookiePath); file.open(QIODevice::ReadOnly); QDataStream in(&file); QList cookies; in >> cookies; setAllCookies(cookies); } void CookieJar::save() { TRACE() << "saving to" << m_cookiePath; QFile file(m_cookiePath); file.open(QIODevice::WriteOnly); QDataStream out(&file); out << allCookies(); /* clear any running timer */ m_saveTimer.stop(); } void CookieJar::queueSave() { m_saveTimer.start(); } CookieJarManager::CookieJarManager(QObject *parent): QObject(parent), d_ptr(new CookieJarManagerPrivate) { Q_D(CookieJarManager); qDBusRegisterMetaType(); qRegisterMetaTypeStreamOperators >("QList"); d->cookieDir = QDesktopServices::storageLocation(QDesktopServices::CacheLocation) + QDir::separator() + "cookies"; if (!d->cookieDir.exists()) { d->cookieDir.mkpath("."); } QObject::connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(saveAll())); } CookieJarManager::~CookieJarManager() { delete d_ptr; } CookieJarManager *CookieJarManager::instance() { if (m_instance == 0) { m_instance = new CookieJarManager(); } return m_instance; } CookieJar *CookieJarManager::cookieJarForIdentity(uint id) { Q_D(CookieJarManager); if (d->cookieJars.contains(id)) { return d->cookieJars[id]; } else { QString fileName = QString::fromLatin1("%1.jar").arg(id); CookieJar *cookieJar = new CookieJar(d->cookieDir.absoluteFilePath(fileName), this); d->cookieJars.insert(id, cookieJar); return cookieJar; } } void CookieJarManager::removeForIdentity(uint id) { Q_D(CookieJarManager); TRACE() << id; QString fileName = QString::fromLatin1("%1.jar").arg(id); d->cookieDir.remove(fileName); } void CookieJarManager::saveAll() { Q_D(CookieJarManager); foreach (CookieJar *jar, d->cookieJars) { jar->save(); } } ./src/main.cpp0000644000015600001650000000752212701152050013313 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "i18n.h" #include "inactivity-timer.h" #include "indicator-service.h" #include "my-network-proxy-factory.h" #include "service.h" #include #include #include #include using namespace SignOnUi; /* This is where signond expects to find us */ static const char serviceName[] = "com.nokia.singlesignonui"; static const char objectPath[] = "/SignonUi"; int main(int argc, char **argv) { QApplication app(argc, argv); app.setApplicationName("signon-ui"); app.setQuitOnLastWindowClosed(false); /* read environment variables */ QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); if (environment.contains(QLatin1String("SSOUI_LOGGING_LEVEL"))) { bool isOk; int value = environment.value( QLatin1String("SSOUI_LOGGING_LEVEL")).toInt(&isOk); if (isOk) setLoggingLevel(value); } /* default daemonTimeout to 30 */ int daemonTimeout = 30; /* override daemonTimeout if SSOUI_DAEMON_TIMEOUT is set */ if (environment.contains(QLatin1String("SSOUI_DAEMON_TIMEOUT"))) { bool isOk; int value = environment.value( QLatin1String("SSOUI_DAEMON_TIMEOUT")).toInt(&isOk); if (isOk) daemonTimeout = value; } QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QLatin1String("/etc")); initTr(I18N_DOMAIN, NULL); /* Use a libproxy-based proxy factory; this code will no longer be * needed when https://bugreports.qt-project.org/browse/QTBUG-26295 * is fixed. */ MyNetworkProxyFactory *proxyFactory = new MyNetworkProxyFactory(); QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory); Service *service = new Service(); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerService(QLatin1String(serviceName)); connection.registerObject(QLatin1String(objectPath), service, QDBusConnection::ExportAllContents); IndicatorService *indicatorService = new IndicatorService(); connection.registerService(QLatin1String(WEBCREDENTIALS_BUS_NAME)); connection.registerObject(QLatin1String(WEBCREDENTIALS_OBJECT_PATH), indicatorService->serviceObject()); InactivityTimer *inactivityTimer = 0; if (daemonTimeout > 0) { inactivityTimer = new InactivityTimer(daemonTimeout * 1000); inactivityTimer->watchObject(service); inactivityTimer->watchObject(indicatorService); QObject::connect(inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit())); } int ret = app.exec(); connection.unregisterService(QLatin1String(WEBCREDENTIALS_BUS_NAME)); connection.unregisterObject(QLatin1String(WEBCREDENTIALS_OBJECT_PATH)); delete indicatorService; connection.unregisterService(QLatin1String(serviceName)); connection.unregisterObject(QLatin1String(objectPath)); delete service; delete inactivityTimer; return ret; } ./src/qml/0000755000015600001650000000000012701152055012453 5ustar jenkinsjenkins./src/qml/WebView.qml0000644000015600001650000000160412701152055014537 0ustar jenkinsjenkinsimport QtQuick 2.0 import Ubuntu.Components 1.3 import Ubuntu.Web 0.2 WebView { id: root Component.onCompleted: url = signonRequest.startUrl onLoadingStateChanged: { console.log("Loading changed") if (loading && !lastLoadFailed) { signonRequest.onLoadStarted() } else if (lastLoadSucceeded) { signonRequest.onLoadFinished(true) } else if (lastLoadFailed) { signonRequest.onLoadFinished(false) } } onUrlChanged: signonRequest.currentUrl = url context: WebContext { dataPath: rootDir } /* Taken from webbrowser-app */ ProgressBar { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right height: units.dp(3) showProgressPercentage: false visible: root.loading value: root.loadProgress / 100 } } ./src/qml/StandardAnimation.qml0000644000015600001650000000152112701152050016560 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ import QtQuick 2.0 NumberAnimation { duration: 300 easing.type: Easing.InOutQuad } ./src/qml/DefaultPage.qml0000644000015600001650000000037012701152055015347 0ustar jenkinsjenkinsimport QtQuick 2.0 import Ubuntu.Components 1.3 Page { Loader { id: loader anchors { fill: parent bottomMargin: osk.height } focus: true sourceComponent: browserComponent } } ./src/qml/MainWindow.qml0000644000015600001650000000076612701152055015253 0ustar jenkinsjenkinsimport QtQuick 2.0 import Ubuntu.Components 1.3 Item { id: root width: units.gu(60) height: units.gu(90) property var signonRequest: request Loader { id: loader property Component webView: browserComponent property Item osk: osk anchors.fill: parent focus: true source: request.pageComponentUrl } KeyboardRectangle { id: osk } Component { id: browserComponent WebView { } } } ./src/qml/qml.qrc0000644000015600001650000000037112701152050013747 0ustar jenkinsjenkins DefaultPage.qml KeyboardRectangle.qml MainWindow.qml StandardAnimation.qml WebView.qml ./src/qml/KeyboardRectangle.qml0000644000015600001650000000346512701152050016556 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ import QtQuick 2.0 Item { id: keyboardRect anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom height: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 Behavior on height { StandardAnimation { } } function recursiveFindFocusedItem(parent) { if (parent.activeFocus) { return parent; } for (var i in parent.children) { var child = parent.children[i]; if (child.activeFocus) { return child; } var item = recursiveFindFocusedItem(child); if (item != null) { return item; } } return null; } Connections { target: Qt.inputMethod onVisibleChanged: { if (!Qt.inputMethod.visible) { var focusedItem = recursiveFindFocusedItem(keyboardRect.parent); if (focusedItem != null) { focusedItem.focus = false; } } } } } ./src/reauthenticator.cpp0000644000015600001650000001032012701152050015556 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "reauthenticator.h" #include "debug.h" #include #include using namespace SignOnUi; using namespace SignOn; namespace SignOnUi { class ReauthenticatorPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(Reauthenticator) public: ReauthenticatorPrivate(const QList &clientData, const QVariantMap &extraParameters, Reauthenticator *reauthenticator); ~ReauthenticatorPrivate(); void start(); private: void checkFinished(); private Q_SLOTS: void onError(const SignOn::Error &error); void onResponse(const SignOn::SessionData &response); private: mutable Reauthenticator *q_ptr; QList m_clientData; QVariantMap m_extraParameters; int m_errorCount; int m_responseCount; }; } // namespace ReauthenticatorPrivate::ReauthenticatorPrivate( const QList &clientData, const QVariantMap &extraParameters, Reauthenticator *request): QObject(request), q_ptr(request), m_clientData(clientData), m_extraParameters(extraParameters), m_errorCount(0), m_responseCount(0) { } ReauthenticatorPrivate::~ReauthenticatorPrivate() { } void ReauthenticatorPrivate::start() { foreach (const AuthData &authData, m_clientData) { Identity *identity = Identity::existingIdentity(authData.identity, this); if (identity == 0) { m_errorCount++; continue; } AuthSession *authSession = identity->createSession(authData.method); if (authSession == 0) { m_errorCount++; continue; } QObject::connect(authSession, SIGNAL(error(const SignOn::Error &)), this, SLOT(onError(const SignOn::Error &))); QObject::connect(authSession, SIGNAL(response(const SignOn::SessionData &)), this, SLOT(onResponse(const SignOn::SessionData &))); /* Prepare the session data, adding the extra parameters. */ QVariantMap sessionData = authData.sessionData; QVariantMap::const_iterator i; for (i = m_extraParameters.constBegin(); i != m_extraParameters.constEnd(); i++) { sessionData[i.key()] = i.value(); } /* Start the session right now; signon-ui is queueing them anyway. */ authSession->process(sessionData, authData.mechanism); } checkFinished(); } void ReauthenticatorPrivate::checkFinished() { Q_Q(Reauthenticator); if (m_errorCount + m_responseCount < m_clientData.count()) return; Q_EMIT q->finished(m_errorCount == 0); } void ReauthenticatorPrivate::onError(const SignOn::Error &error) { TRACE() << "Got error:" << error.message(); m_errorCount++; checkFinished(); } void ReauthenticatorPrivate::onResponse( const SignOn::SessionData &response) { TRACE() << "Got response:" << response.toMap(); m_responseCount++; checkFinished(); } Reauthenticator::Reauthenticator(const QList &clientData, const QVariantMap &extraParameters, QObject *parent): QObject(parent), d_ptr(new ReauthenticatorPrivate(clientData, extraParameters, this)) { } Reauthenticator::~Reauthenticator() { } void Reauthenticator::start() { Q_D(Reauthenticator); d->start(); } #include "reauthenticator.moc" ./src/debug.h0000644000015600001650000000273312701152050013121 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DEBUG_H #define SIGNON_UI_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 // SIGNON_UI_DEBUG_H ./src/webcredentials_interface.cpp0000644000015600001650000000420012701152050017370 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "webcredentials_interface.h" #include "indicator-service.h" /* * We don't use the code generated by qdbusxml2cpp, because the * IndicatorService is provided by the signon-ui process itself, and it would * be silly to send requests to it via D-Bus. * So, this class wraps the real IndicatorService methods, so that they can be * called directly, while still leaving the external API as if it were * generated by qdbusxml2cpp (in case we later decide to move this service * somewhere else). */ using namespace SignOnUi; ComCanonicalIndicatorsWebcredentialsInterface:: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QObject(parent) { Q_UNUSED(service); Q_UNUSED(path); Q_UNUSED(connection); } ComCanonicalIndicatorsWebcredentialsInterface::~ComCanonicalIndicatorsWebcredentialsInterface() { } QDBusPendingReply<> ComCanonicalIndicatorsWebcredentialsInterface::ReportFailure(uint account_id, const QVariantMap ¬ification) { Q_ASSERT(IndicatorService::instance() != 0); IndicatorService::instance()->reportFailure(account_id, notification); return QDBusPendingReply<>(); } ./src/spinner-26.gif0000644000015600001650000002112312701152050014246 0ustar jenkinsjenkinsGIF89a õÿÿÿªªª„„„```LLL>>>HHHVVVpppŽŽŽ   fff444222888BBBttt¦¦¦®®®jjj000°°°***\\\”””&&&"""ˆˆˆ˜˜˜~~~RRRzzz œœœººº´´´¾¾¾ÎÎÎÒÒÒØØØÈÈÈÄÄÄâââìììæææðððöööüüüÜÜÜ !ÿ NETSCAPE2.0!þCreated with ajaxload.info!ù , ÿ@€pHœ ŽKÉAl:Ÿ€"t:•JV¨–( lF×ð ²Ý. ¡t:|-C3—z>¸ ÇF.Z? wE"Š„P’‡ŽP ‘–P ™š•ŸN ª¦O« ®M³ v¶MÀ ½MÆÄDÇËC͵ÑÙƒÑÙÙÜ ßâ ê ÜñÃÜóÛËóú¸»CcË ú0H@ÂÍŒ‚Z,0H¸„P`ÈxXF "€ð `…*V°`ñ"Œ@ÄCa¡È2t`ÁD D,5¤AT‹!A „I.€¶„ñr† n ê°@Š?Yº„á+N<ªòÙO&,pº`‚ ”,Ê!ù , ÿ@€pHœ 0J©Ôx @Ĩ”¸@hB¡¥¶tM¿BC#°¡‘Ö¦OÍfƒÆª—7‰;Úyhäevw%{Tr"  ‡BŠ‹—` ›¤¡` ¤  ©` µ®P²S¼¼¹_ÃÀS Ä¿ÈRÒ¨ÎQ××mÕDØÇÛCÝàáÝÚèèBò öúX`O€> =ôƒç¶IÈ€B‚zÐq`ð0ˆ·Yq1€ ¤ø2ƒÆ%bžTa*X¼ˆcFËBPd¢ì°`‚ œ:aÈøÊ” ˆEº³'ÓK(HH"*EŠ+jð\ÚÒe( ¸Z8šS¬ÒÎL @ÁvEÒ=A!ù , ÿ@€pHœp0FHôx ¢t:\`.Ñ&4•¾§bA¥ (•‹F“冸ßÒéD(‡´z-½ßq'7$vB‰{m%^_6… ˜‹ ‘”Išše ”M ”º µ¾ ºº ¾µ¹Á…ÊuÇ… ÒÒÏ… ÓÎÖeÜvß­äTïdëSï„òRõêùCô#ÀÀ! d`ì € DàÀ $~ª@ÄH¨8A〠LT RA†*Z8ÉAA‡L¨‰Òæ‚D &\¨¨ÆŒ4hX³!‰‚ª`ñ† ¤äL,xU(U«XÉ¥° ¡ëÔªW•ÊsaB* ¢F‘ª•§b*Ü´sË!ù , ÿ@€pHœ(Ãf“$ &Ĩt¸ 4.Xf…4ˆÅt*H<*Gv+ ¹G¥A0J>t¾rÑnDmnq%bc yj}Km^ƒ%" SIIŒ #pq87R›c ƒ'S ¾±uC '7˜¾Ë—ÃCcʾÎØÜÜÙØÜaàÎ ååßçà NíÃööµôc÷ úûú1Hð ”D0d„@äk8DBšQ²@¡‡Œ&6 ±#‡ 7fÀAA!EZhùrÁ„",PÐaG &Tˆ4A‚„M)Z°ˆ±Ñ„O .T°xCÆ 4š˜U*U«Y º0a"êÔªW)ªpaökÚ,Vœ‹5gŒ0fè­‹-!ù , ÿ@€pHœ(Èå18¢t:”0 Ge{ÑxEÄ‚JD †Ç£‘­t½‘hC«˜&:Ý^~E!!#cd$I{k ~q€!%%Tˆ‰M  “…Cšd"##“%vC°ÂwC "»“UÏ–Å¿º“66BÍÓR %'7¬ÜÜáSRóó«íBÙR  ì÷¦E`@AiïDHÀ0‚½„SDˆDˆd$‚0à"Æ)9BùH…G |‘$Òƒ‚ ò­¬‚² .f1óæU:«X … A˜X Á‚ *j$E1E ¨,buaêŠ1`ÌÐÙâ© /`ȘAƒÆL-Φ]ëV'‹»ag°M àÅܽ|ÃÒ­Ë€^Àƒ!ù , ÿ@€pHœ(‡ƒ£‘d(&Ĩt(I@ ؇£Â½\*˜Åt:’Wl£ápx5š A0¦çCÚð`»/p"bc ‰IY}mo""!SŠI €‚“#…Cš c’!!#%PC¯±±uCº!%%vеÆÀ#»Ì…ÑÐ ÕQ ¼Ì%  àRäÌ$ ööïQä''Dˆb€>)JظaƒÀ <€ q0 ‚ òˆ8 #Šu:à È:$„2qrŒ:,`ÙRJL $ЬI„ÞVvò‚BP)X âBBÐ.T,biT/¦Paâj0´ªP±+ 3¦²P5Ú4h,eaV\¹S_¸W«³|ñúx0Á†—!ù , ÿ@€pHdˆ‚ÁP(P“¢t*I|XÈÒðp8„Åt:$›ØÃ¶[iW(‚ñPBA >…´zùhx+bc vvxi|}^S ˆ  Ž„C –—˜ ©E¦¦QC –– rCµ"!ÇC½Ì°ÂD""##„ ÚÚÏEÆ!Õ( ç ÁÞEÇ#%# õõì²%Ç%% 8(P0)_‘ýú˜¡aƒD$,Ñ ƒE L@$âa¢%Hp±qWÂ%DN°`¡EI! N–X‰ÂD /§˜°éÂÅŠEœRzºP¡‚Ð"*ZeQ#ÆÑ!,ŠÖxÆS¨,^À€!cÆU1¨v1ƒÆ×­di¨5{5-Û¯ÒÂ%¢v®Ý»xóÊ !ù , ÿ@€pHt@Ìá€A$“¢t*5?…ìò`è2Ó©el" Û¤kh<‚ðpb’ˆ)B(À‚C(\,Â@aˆLhtáBÅD"J(,±!Ç*X|”VbĈ%PªXÁâÅJ! `êLɢƋI7„Ô)‚EÍ0`% ³Äƒ/’˜ôŽ6N|@:uÆ AL` !€®4Ò†-âUíZ¶_ßN‰+W غxóêÝË·ïÛ !ù , ÿ@€pHt< ¢@ D2“¢t*P„vY8x)’éÔ¢HP®Mí§ë… xh$±öÜ s wIY~’S( ‡‰Š $ “ „E¢™ aSQC ìs ºC. $¡¢ÇD »¬&á Ö×DÜÜ*(ðåæDø-&ýý-ôŠdÈ·aƒ-\(tPŠ " "PA‘⊆ElÑ‹k`$2 Dˆ!.¼XãEŒ‘Cœ1BŒ›8a ‘I³¦ŒT3dÈ€¡Y š%4]:£(PK< A•jS¢–(@c«#œ€zâ"Tuj(1v,­¢C@à¸QÜ) nà0v·H‚¾€ L¸°á€A!ù , ÿ@€pH,8‘Cax2Ũ`Q$MÁ-|’iÔD€"W†–‹( @,4e83(ÕboaS& ‹g|j”R) $ x ‚•‡DœŸS$–­­¸C)¦Àt½ C*)&&(²&tD Í B*-..Ó.ØEÜ 5+*óäèQìì /5,ÿ*XØ+’]… ÄXØOàÀ"^¸@†Å…1aPAƒÇ3fȰC#‘6¤¬²¥ “Cl±¡&›4B¢@„Ï]šCrÎØ `@ˆ£".¡Aƒ#F„0дȃ£QTYjT[…<(µ„XMœ(Áö„Ö­ J¬e[ÜV7æž VÈ€¼'.Ìé ïˆL„ý*H̸±c˜A!ù , ÿ@€pHL:O" :Ũ`Zdƒ(²d¾ É4ê²,:WNÔýbÏd,l¡’)­åz obS*&&zil ^p$R,-..ˆ‹ { €p…D+*±.)ˆ.S ¼sC/,ð-*tB•½C01/ÒÃ,ÈC¼Û B0ßß11ÖDÛÛB2332ßäEèíøíñDÛÌ Aà¾":¨@À ‰$hà âˆ¥ ¨¸ðAÆ)*T¸@ò£$/h¸`2Ê•48hY„AÌ  Ð$b`ƒÏU v É ¢è„8BDÓ ®Z&A•jÐF8 1BC7š J”Áuš4ˆ][¢€p° E¨b5(PºÔFÛ¯|7`xËWHÔÂc‚!ù , ÿ@€pH˜$gÀT,ŠÐ( u\t2 ÅÀIx)”EEY$Vì¶› ƒ‰XXSµ\&3:¹ub/,+**x&$Y~ €‚OP01/5ˆ‹&¡¡(H”©…E0®œ,Š*R ¨rC3322›//sB © ½¾¾Á0ÅC¸Ë¬4Û4ÏÓD Ëã B4CÝßE ãaDÛêDãôÅùù øÍ‰ðÏÀb8<0ð`!B)>pÐàa” 8¨PÑb‘BVxà±H‘”$ràÂ… ¬’Aƒ† 7÷Í< aƒÍT ¬JF!¢§™+l *Âg& D„`*©EJ„غõA<„”Ëu„œ[bÄØ J2°Áv샧m¬]‹ákI½!>à]™Áƒ_(A!ù , ÿ@€pH´LÉ"ÃìHŠÐ(àµr¹LeFÁx@ 4«­TW”`ÑQ(¼‘DBaa±kÕºfI[ q bR332xzhXZoƒr R44‹x,**}~ “ ¨OQ›3/R¦¨™œvB§µ¹2»C$ÀÀªE›ÅD ÀÏÏ ÓÛˆ×c$Ô Þ»é æv éíc ðôRýýúQ2øû°‡ Ið áƒ ‰hà "ˆ¼TÐè@Æ+ThЭ`„ (E2À8à‚ )1)L°¡æË  "„MC%Ÿ¹I@ B‰ž=kV AïA‰§GCŒáóB}%N@•:5„™ô h…ZbÄAÍXË6° œ¸PáÃ\c‚!ù , ÿ@€pH¼X*W eL,ŨTƒWI“E²È(ÐitF†ÅŽÙmWÁtÂbm>“YY+— 5YtØ qC4e15+-)&~  …r‡U‰Hz’ ˜‡3S&¡£pRs˜ ”£ ˜» ·¿—»…¿˜ ¿¦Êb Î Òq×ÚbàS äèRìïQóùöE ùóûD"€0À! (4@á €ààÁƒˆ£íá cƒ rhб‚ƒ F¨p¡‚K öe8 ¡fË 4B@ ‚M<±¡¦† P*{P¢iÓ!DˆÐPTà Òn8µë†¢R*[`ckˆh‰j` s—'œ>¡Xm>¸,q¢Âƒâ!ù , ÿ@€pHÐf3X¬ÆRµ\Ũ´xT¾š.“Å’šz‡UØU•HÓWJ«ÆÆeI'ÓA­‰m¤²¶r¥P  „wCH2VMg ‡_. ’•_  Ÿ_£¤ †¨S ¬ °^­ ”·Q ¼¿RÄÄ ÇQ ÊÍEÖÓD$×ÖÚCÕßB åæ ëÙæö æü§ß00ß«i *̧M ,ÐáEˆ"¬p`” Tpà Áƒ§ØÀq¢S "00 áÂ…‘#%®Qp¢„ÏC#F„ºACÍ H t¸sã„S A…†(Zóæ‰k:8} U¨ˆ Eo2HùeÁ‡\ƒNýzVTª” 1Â"‚I_‚!ù , ÿ@€pH$Òf3ìU+:ŸOÚQùb©®Ð¬ó([Z]¦”K«•&cUØ2I‘£Çsm¥J™&‹êýœuc_&( &|Z,k… {‰Y.„ $’Z&$—˜›Y  £Y¨  ¬O° š´N± ¼N ¹ ÃE$ Î ÊD ÕÑC ÖרáÝØçÐÞ çÞ$óó«Øùåÿÿà=¹•H HxâD‰o<˜xB2b6p”(ñ ”L¤ø¡_‘6ll\i€ª pÐàȉ<‘°ae‰O@EÕ áB… hŠ<Ð!Ë‚KŒ4Ñ¢G+Ð, S‹ +§ŽØ bQ£G$0ùfÁ‡ !¨n˜{öÂ]7M0g3Ä‘8ˆÊ!ù , ÿ@€pH,i´™qÉd"g0X¬I]>¥¯Zu xBcµ•jÅu&¡°KårµÊÌ™LZ[»L(œ™¶§P{M,m& ‚ƒK*x‰&ŒK.‘ ”K   (›E& £E¨ «D  ²C·¾ºB¾ ÄÀÄÉÆ$ Î Æ ÔÆ ÔÔFŒ EŒ ëëC7'%Ðp÷ÛB!'òò¹¸d8P ` ª„`(!¯D‰ô¨ 8@‘à}B&\h8"Äå–t@¡"E ‹†tá0„Ë P‘!ˆ0`²€&U# D8ÑQÄ .8Xú@çN h²àAÇŽ0&­ÀtçN › "„Ñ G/TàZ¡AS Üqù¦&Ò j¹:0À ,œ 0ìÄ[’‚”K‚!ù , ÿ@€pH,Èd’¦l6i3§´•Á¦R‹a—Ú™5V{}á öb±ÎH5»¶R©àÇ9KåJÝñEm|.&&€F|)&.‡D+ІC‹ —˜›žB&$ ¤&© ¬(°¶¬¶»C€$  ¶'6% €Ï ''%Ö p ÛÛ$Öàp  Õà _ òòB à!#õRóò: !`-„Á Àšp@Àü„pPb„Á"¬:ÒA 0˜P„Ä…ClÐpá@28ûp æX$ÃOŒ"6¬¼àÀAƒ °ù$‰$ ]ɲèQ¥ Ô,p`g4ˆ½p¡‚Q¤X·‚ )e† d+ÈuT)„<±Là@ fÑ›°E!ù , ÿ@€pH,ȤrÉl:ŸÐ(6‹2§U+rJÁ´G¬ghìÅ6eêWÅrcr–ªµ² c,+{.-~Bƒ.&)†*‰&((Œ*f.— %''%%`. ¬"§§`(®·±%` ¿ ¦§`¦!!¨VÊÊ #%##!V ââÜÝ"³O ï B ÜÐN  þ †€vïÂ:% (dàOÞ6HÜ áÂHH$@€A!Ê!qA¢†Šˆ0ÀÕÈä¸P‘ N^¸PÁAHMœ-ðáÃL ’,€°³BÏŸœ j›J0pêÔÁ&N†(€`@À&  * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "embed-manager.h" #include #include #include #include #include using namespace SignOnUi; static EmbedManager *staticInstance = 0; namespace SignOnUi { class EmbedManagerPrivate { public: EmbedManagerPrivate(); ~EmbedManagerPrivate(); private: friend class EmbedManager; QMap > m_embedWidgets; }; } // namespace /* Workaround for https://bugreports.qt-project.org/browse/QTBUG-3617 * Send XEMBED_REQUEST_FOCUS manually. */ #define XEMBED_REQUEST_FOCUS 3 // Sends an XEmbed message. static void sendXEmbedMessage(WId window, Display *display, long message, long detail = 0, long data1 = 0, long data2 = 0) { XClientMessageEvent c; memset(&c, 0, sizeof(c)); c.type = ClientMessage; c.message_type = XInternAtom(display, "_XEMBED", false); c.format = 32; c.display = display; c.window = window; c.data.l[0] = QX11Info::appTime(); c.data.l[1] = message; c.data.l[2] = detail; c.data.l[3] = data1; c.data.l[4] = data2; XSendEvent(display, window, false, NoEventMask, (XEvent *) &c); } static bool x11EventFilter(void *message, long *) { XEvent *event = reinterpret_cast(message); if (event->type == ButtonPress) { QWidget *w = QWidget::find(event->xbutton.window); if (w && w->window()->objectName() == "request-widget") { QX11EmbedWidget *embed = static_cast(w->window()); QApplication::setActiveWindow(w->window()); sendXEmbedMessage(embed->containerWinId(), w->x11Info().display(), XEMBED_REQUEST_FOCUS); } } return false; } EmbedManagerPrivate::EmbedManagerPrivate() { } EmbedManagerPrivate::~EmbedManagerPrivate() { } EmbedManager *EmbedManager::instance() { if (staticInstance == 0) { staticInstance = new EmbedManager(); } return staticInstance; } EmbedManager::EmbedManager(QObject *parent): QObject(parent), d_ptr(new EmbedManagerPrivate) { QCoreApplication::instance()->setEventFilter(x11EventFilter); } EmbedManager::~EmbedManager() { delete d_ptr; } QX11EmbedWidget *EmbedManager::widgetFor(WId windowId) { Q_D(EmbedManager); QX11EmbedWidget *embed = d->m_embedWidgets.value(windowId, 0); if (embed == 0) { /* Create a new embed widget */ embed = new QX11EmbedWidget; QObject::connect(embed, SIGNAL(containerClosed()), embed, SLOT(deleteLater())); embed->embedInto(windowId); embed->setObjectName("request-widget"); d->m_embedWidgets[windowId] = embed; } return embed; } ./src/indicator-service.cpp0000644000015600001650000002452612701152050016004 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "indicator-service.h" #include "debug.h" #include "i18n.h" #include "reauthenticator.h" #include "webcredentials_adaptor.h" #include #include #undef signals #include #include using namespace SignOnUi; QDBusArgument &operator<<(QDBusArgument &argument, const QSet &set) { argument.beginArray(qMetaTypeId()); foreach (uint id, set) { argument << id; } argument.endArray(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, QSet &set) { argument.beginArray(); while (!argument.atEnd()) { uint id; argument >> id; set.insert(id); } argument.endArray(); return argument; } namespace SignOnUi { static IndicatorService *m_instance = 0; class IndicatorServicePrivate: public QObject, QDBusContext { Q_OBJECT Q_DECLARE_PUBLIC(IndicatorService) public: Q_PROPERTY(QSet Failures READ failures) Q_PROPERTY(bool ErrorStatus READ errorStatus) IndicatorServicePrivate(IndicatorService *service); ~IndicatorServicePrivate() {}; QSet failures() const { return m_failures; } bool errorStatus() const { return m_errorStatus; } public Q_SLOTS: void ClearErrorStatus(); void RemoveFailures(const QSet &accountIds); void ReportFailure(uint accountId, const QVariantMap ¬ification); bool ReauthenticateAccount(uint accountId, const QVariantMap &extraParameters); private: void showNotification(const QVariantMap ¶meters); void notifyPropertyChanged(const char *propertyName); private Q_SLOTS: void onReauthenticatorFinished(bool success); private: mutable IndicatorService *q_ptr; WebcredentialsAdaptor *m_adaptor; QSet m_failures; QMap > m_failureClientData; QMap m_reauthenticators; QDBusMessage m_clientMessage; bool m_errorStatus; }; } // namespace IndicatorServicePrivate::IndicatorServicePrivate(IndicatorService *service): QObject(service), q_ptr(service), m_adaptor(new WebcredentialsAdaptor(this)), m_errorStatus(false) { qDBusRegisterMetaType< QSet >(); notify_init("webcredentials-indicator"); } void IndicatorServicePrivate::ClearErrorStatus() { if (m_errorStatus) { m_errorStatus = false; notifyPropertyChanged("ErrorStatus"); } } void IndicatorServicePrivate::RemoveFailures(const QSet &accountIds) { Q_Q(IndicatorService); m_failures.subtract(accountIds); notifyPropertyChanged("Failures"); if (q->isIdle()) { Q_EMIT q->isIdleChanged(); } } void IndicatorServicePrivate::ReportFailure(uint accountId, const QVariantMap ¬ification) { Q_Q(IndicatorService); bool wasIdle = q->isIdle(); m_failures.insert(accountId); if (wasIdle) { Q_EMIT q->isIdleChanged(); } /* If the original client data is provided, we remember it: it can * be used to replay the authentication later. */ if (notification.contains("ClientData")) { /* If the key is not found, the QMap's [] operator inserts an empty * element in the map and return a reference to it. So the following * line of code returns a valid QList even if the account never failed * before. */ QList &failedAuthentications = m_failureClientData[accountId]; AuthData authData; authData.sessionData = notification["ClientData"].toMap(); authData.identity = quint32(notification["Identity"].toUInt()); authData.method = notification["Method"].toString(); authData.mechanism = notification["Mechanism"].toString(); failedAuthentications.append(authData); } notifyPropertyChanged("Failures"); showNotification(notification); } bool IndicatorServicePrivate::ReauthenticateAccount(uint accountId, const QVariantMap &extraParameters) { if (!m_failureClientData.contains(accountId)) { /* Nothing we can do about this account */ TRACE() << "No reauthentication data for account" << accountId; return false; } if (m_reauthenticators.contains(accountId)) { /* A reauthenticator for this account is already at work. This * shouldn't happen in a real world scenario. */ qWarning() << "Reauthenticator already active on" << accountId; return false; } TRACE() << "Reauthenticating account" << accountId; /* If we need to reauthenticate, we are delivering the result * after iterating the event loop, so we must inform QtDBus that * it shouldn't use this method's return value as a result. */ setDelayedReply(true); m_clientMessage = message(); QList &failedAuthentications = m_failureClientData[accountId]; Reauthenticator *reauthenticator = new Reauthenticator(failedAuthentications, extraParameters, this); m_reauthenticators[accountId] = reauthenticator; QObject::connect(reauthenticator, SIGNAL(finished(bool)), this, SLOT(onReauthenticatorFinished(bool)), Qt::QueuedConnection); reauthenticator->start(); return true; // ignored, see setDelayedReply() above. } void IndicatorServicePrivate::showNotification(const QVariantMap ¶meters) { /* Don't show more than one notification, until the error status is * cleared */ if (m_errorStatus) return; m_errorStatus = true; notifyPropertyChanged("ErrorStatus"); QString applicationName = parameters.value("DisplayName").toString(); QString summary; if (applicationName.isEmpty()) { summary = _("Applications can no longer access " "some of your Online Accounts"); } else { summary = _("Applications can no longer access " "your %1 Online Account").arg(applicationName); } QString message = _("Choose Online Accounts from the user " "menu to reinstate access to this account."); QByteArray summaryUtf8 = summary.toUtf8(); QByteArray messageUtf8 = message.toUtf8(); NotifyNotification *notification = notify_notification_new(summaryUtf8.constData(), messageUtf8.constData(), NULL); GError *error = NULL; if (!notify_notification_show(notification, &error)) { BLAME() << "Couldn't show notification:" << error->message; g_clear_error(&error); } g_object_unref(notification); } void IndicatorServicePrivate::notifyPropertyChanged(const char *propertyName) { QDBusMessage signal = QDBusMessage::createSignal(WEBCREDENTIALS_OBJECT_PATH, "org.freedesktop.DBus.Properties", "PropertiesChanged"); signal << WEBCREDENTIALS_INTERFACE; QVariantMap changedProps; changedProps.insert(QString::fromLatin1(propertyName), property(propertyName)); signal << changedProps; signal << QStringList(); QDBusConnection::sessionBus().send(signal); } void IndicatorServicePrivate::onReauthenticatorFinished(bool success) { Q_Q(IndicatorService); Reauthenticator *reauthenticator = qobject_cast(sender()); /* Find the account; searching a map by value is inefficient, but * in this case it's extremely likely that the map contains just * one element. :-) */ uint accountId = 0; QMap::const_iterator i; for (i = m_reauthenticators.constBegin(); i != m_reauthenticators.constEnd(); i++) { if (i.value() == reauthenticator) { accountId = i.key(); break; } } Q_ASSERT (accountId != 0); QDBusMessage reply = m_clientMessage.createReply(success); QDBusConnection::sessionBus().send(reply); if (success) { m_failureClientData.remove(accountId); m_failures.remove(accountId); notifyPropertyChanged("Failures"); if (m_failures.isEmpty()) { ClearErrorStatus(); Q_EMIT q->isIdleChanged(); } } m_reauthenticators.remove(accountId); reauthenticator->deleteLater(); } IndicatorService::IndicatorService(QObject *parent): QObject(parent), d_ptr(new IndicatorServicePrivate(this)) { if (m_instance == 0) { m_instance = this; } else { BLAME() << "Instantiating a second IndicatorService!"; } } IndicatorService::~IndicatorService() { m_instance = 0; delete d_ptr; } IndicatorService *IndicatorService::instance() { return m_instance; } QObject *IndicatorService::serviceObject() const { return d_ptr; } void IndicatorService::clearErrorStatus() { Q_D(IndicatorService); d->ClearErrorStatus(); } void IndicatorService::removeFailures(const QSet &accountIds) { Q_D(IndicatorService); d->RemoveFailures(accountIds); } void IndicatorService::reportFailure(uint accountId, const QVariantMap ¬ification) { Q_D(IndicatorService); d->ReportFailure(accountId, notification); } QSet IndicatorService::failures() const { Q_D(const IndicatorService); return d->m_failures; } bool IndicatorService::errorStatus() const { Q_D(const IndicatorService); return d->m_errorStatus; } bool IndicatorService::isIdle() const { Q_D(const IndicatorService); return d->m_failures.isEmpty(); } #include "indicator-service.moc" ./src/dialog-request.cpp0000644000015600001650000002057112701152050015313 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "dialog-request.h" #include "debug.h" #include "dialog.h" #include "i18n.h" #include "network-access-manager.h" #include #include #include #include #include #include #include #include #include #include using namespace SignOnUi; using namespace SignOn; namespace SignOnUi { class DialogRequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(DialogRequest) public: DialogRequestPrivate(DialogRequest *request); ~DialogRequestPrivate(); void buildDialog(const QVariantMap ¶ms); void start(); private Q_SLOTS: void onAccepted(); void onRejected(); void onCaptchaRetrieved(QNetworkReply *reply); private: QString messageFromId(int id); void requestCaptcha(const QUrl &url); private: mutable DialogRequest *q_ptr; Dialog *m_dialog; bool m_queryUsername; bool m_queryPassword; QLineEdit *m_wUsername; QLineEdit *m_wPassword; QLineEdit *m_wCaptchaText; QLabel *m_wCaptcha; QNetworkAccessManager *m_networkAccessManager; }; } // namespace DialogRequestPrivate::DialogRequestPrivate(DialogRequest *request): QObject(request), q_ptr(request), m_dialog(0), m_queryUsername(false), m_queryPassword(false), m_wUsername(0), m_wPassword(0), m_wCaptchaText(0), m_wCaptcha(0), m_networkAccessManager(0) { } DialogRequestPrivate::~DialogRequestPrivate() { delete m_dialog; } QString DialogRequestPrivate::messageFromId(int id) { static QString error = QLatin1String("%1"); static QString msg = QLatin1String("%1"); switch (id) { case QUERY_MESSAGE_LOGIN: return msg.arg(_("Enter your credentials to login")); case QUERY_MESSAGE_NOT_AUTHORIZED: return error.arg(_("Previous authentication attempt failed. Please try again.")); case QUERY_MESSAGE_EMPTY: default: return QString(); } } void DialogRequestPrivate::requestCaptcha(const QUrl &url) { TRACE() << url; if (m_networkAccessManager == 0) { m_networkAccessManager = NetworkAccessManager::instance(); } QNetworkRequest request = QNetworkRequest(url); QNetworkReply *reply = m_networkAccessManager->get(request); if (reply->isFinished()) { onCaptchaRetrieved(reply); } else { // FIXME: handle download asynchronously QEventLoop loop; QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); onCaptchaRetrieved(reply); } } void DialogRequestPrivate::buildDialog(const QVariantMap ¶ms) { m_dialog = new Dialog; m_dialog->setObjectName("LoginDialog"); m_dialog->setMinimumWidth(400); QString title = params.value(SSOUI_KEY_TITLE, _("Enter your credentials")).toString(); m_dialog->setWindowTitle(title); QFormLayout *formLayout = new QFormLayout(m_dialog); QString message = params.value(SSOUI_KEY_MESSAGE).toString(); if (message.isEmpty()) { // Check whether a predefined message id is set if (params.contains(SSOUI_KEY_MESSAGEID)) { message = messageFromId(params.value(SSOUI_KEY_MESSAGEID).toInt()); } } if (!message.isEmpty()) { QLabel *wMessage = new QLabel(message); wMessage->setObjectName("Message"); formLayout->addRow(wMessage); } m_queryUsername = params.value(SSOUI_KEY_QUERYUSERNAME, false).toBool(); bool showUsername = m_queryUsername || params.contains(SSOUI_KEY_USERNAME); if (showUsername) { m_wUsername = new QLineEdit; m_wUsername->setObjectName("UsernameField"); m_wUsername->setEnabled(m_queryUsername); #ifndef QT_NO_ACCESSIBILITY m_wUsername->setAccessibleName("username"); #endif m_wUsername->setText(params.value(SSOUI_KEY_USERNAME).toString()); formLayout->addRow(_("Username:"), m_wUsername); } m_queryPassword = params.value(SSOUI_KEY_QUERYPASSWORD, false).toBool(); bool showPassword = m_queryPassword || params.contains(SSOUI_KEY_PASSWORD); if (showPassword) { m_wPassword = new QLineEdit; m_wPassword->setObjectName("PasswordField"); m_wPassword->setEnabled(m_queryPassword); m_wPassword->setEchoMode(QLineEdit::Password); m_wPassword->setText(params.value(SSOUI_KEY_PASSWORD).toString()); formLayout->addRow(_("Password:"), m_wPassword); } QString captchaUrl = params.value(SSOUI_KEY_CAPTCHAURL).toString(); if (!captchaUrl.isEmpty()) { QLabel *wCaptchaMsg = new QLabel(QString::fromLatin1("%1"). arg(_("As an additional security measure, please " "fill in the text from the picture below:"))); wCaptchaMsg->setWordWrap(true); formLayout->addRow(wCaptchaMsg); m_wCaptcha = new QLabel; m_wCaptcha->setAlignment(Qt::AlignCenter); formLayout->addRow(m_wCaptcha); m_wCaptchaText = new QLineEdit; m_wCaptchaText->setObjectName("CaptchaField"); formLayout->addRow(_("Text from the picture:"), m_wCaptchaText); requestCaptcha(QUrl::fromEncoded(captchaUrl.toLatin1())); } QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), m_dialog, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), m_dialog, SLOT(reject())); formLayout->addRow(buttonBox); TRACE() << "Dialog was built"; } void DialogRequestPrivate::start() { Q_Q(DialogRequest); buildDialog(q->parameters()); q->setWidget(m_dialog); QObject::connect(m_dialog, SIGNAL(accepted()), this, SLOT(onAccepted())); QObject::connect(m_dialog, SIGNAL(rejected()), this, SLOT(onRejected())); } void DialogRequestPrivate::onAccepted() { Q_Q(DialogRequest); TRACE() << "Dialog is accepted"; QVariantMap reply; if (m_queryUsername) { Q_ASSERT(m_wUsername != 0); reply[SSOUI_KEY_USERNAME] = m_wUsername->text(); } if (m_queryPassword) { Q_ASSERT(m_wPassword != 0); reply[SSOUI_KEY_PASSWORD] = m_wPassword->text(); } if (m_wCaptchaText != 0) { reply[SSOUI_KEY_CAPTCHARESP] = m_wCaptchaText->text(); } q->setResult(reply); } void DialogRequestPrivate::onRejected() { Q_Q(DialogRequest); TRACE() << "Dialog is rejected"; q->setCanceled(); } void DialogRequestPrivate::onCaptchaRetrieved(QNetworkReply *reply) { TRACE() << "Got captcha"; reply->deleteLater(); if (reply->error()) { // TODO handle error TRACE() << "Got error:" << reply->errorString(); return; } QUrl newUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (newUrl.isEmpty()) { QByteArray captchaData = reply->readAll(); QPixmap pixmap; pixmap.loadFromData(captchaData); m_wCaptcha->setPixmap(pixmap); } else { QUrl url = reply->url().resolved(newUrl); requestCaptcha(url); } } DialogRequest::DialogRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): Request(connection, message, parameters, parent), d_ptr(new DialogRequestPrivate(this)) { } DialogRequest::~DialogRequest() { } void DialogRequest::start() { Q_D(DialogRequest); Request::start(); d->start(); } #include "dialog-request.moc" ./src/errors.h0000644000015600001650000000205312701152050013342 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_ERRORS_H #define SIGNON_UI_ERRORS_H #define SIGNON_UI_ERROR_PREFIX "com.canonical.SignonUi" #define SIGNON_UI_ERROR_EMBEDDING_FAILED \ SIGNON_UI_ERROR_PREFIX ".EmbeddingFailed" #define SIGNON_UI_ERROR_INTERNAL \ SIGNON_UI_ERROR_PREFIX ".InternalError" #endif // SIGNON_UI_ERRORS_H ./src/ubuntu-browser-request.h0000644000015600001650000000274512701152050016527 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2014 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_UBUNTU_BROWSER_REQUEST_H #define SIGNON_UI_UBUNTU_BROWSER_REQUEST_H #include "request.h" #include namespace SignOnUi { class UbuntuBrowserRequestPrivate; class UbuntuBrowserRequest: public Request { Q_OBJECT public: explicit UbuntuBrowserRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~UbuntuBrowserRequest(); // reimplemented virtual methods void start(); private: UbuntuBrowserRequestPrivate *d_ptr; Q_DECLARE_PRIVATE(UbuntuBrowserRequest) }; } // namespace #endif // SIGNON_UI_UBUNTU_BROWSER_REQUEST_H ./src/signon-ui.pro0000644000015600001650000000622512701152050014314 0ustar jenkinsjenkinsinclude(../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) include($${TOP_SRC_DIR}/common-installs-config.pri) TEMPLATE = app TARGET = signon-ui I18N_DOMAIN = signon-ui CONFIG += \ link_pkgconfig \ qt QT += \ core \ dbus \ gui \ network \ quick \ webkit PKGCONFIG += \ signon-plugins-common \ libnotify \ libproxy-1.0 lessThan(QT_MAJOR_VERSION, 5) { PKGCONFIG += \ accounts-qt \ libsignon-qt \ x11 } else { QT += \ webkitwidgets \ widgets PKGCONFIG += \ accounts-qt5 \ libsignon-qt5 CONFIG(force-foreign-qwindow) { DEFINES += FORCE_FOREIGN_QWINDOW } } HEADERS = \ animation-label.h \ browser-request.h \ cookie-jar-manager.h \ debug.h \ dialog-request.h \ dialog.h \ errors.h \ http-warning.h \ i18n.h \ inactivity-timer.h \ indicator-service.h \ network-access-manager.h \ reauthenticator.h \ request.h \ service.h \ webcredentials_interface.h SOURCES = \ animation-label.cpp \ browser-request.cpp \ cookie-jar-manager.cpp \ debug.cpp \ dialog-request.cpp \ dialog.cpp \ http-warning.cpp \ i18n.cpp \ inactivity-timer.cpp \ indicator-service.cpp \ main.cpp \ my-network-proxy-factory.cpp \ network-access-manager.cpp \ reauthenticator.cpp \ request.cpp \ service.cpp \ webcredentials_interface.cpp lessThan(QT_MAJOR_VERSION, 5) { HEADERS += embed-manager.h SOURCES += embed-manager.cpp } COMMANDLINE = "" CONFIG(use-ubuntu-web-view) { DEFINES += USE_UBUNTU_WEB_VIEW HEADERS += \ qquick-dialog.h \ ubuntu-browser-request.h SOURCES += \ qquick-dialog.cpp \ ubuntu-browser-request.cpp OTHER_FILES += \ qml/DefaultPage.qml \ qml/KeyboardRectangle.qml \ qml/MainWindow.qml \ qml/StandardAnimation.qml \ qml/WebView.qml RESOURCES += \ qml/qml.qrc QMAKE_SUBSTITUTES += \ signon-ui.desktop.in desktop.path = $${INSTALL_PREFIX}/share/applications desktop.files += signon-ui.desktop INSTALLS += desktop COMMANDLINE += " --desktop_file_hint=$${INSTALL_PREFIX}/share/applications/signon-ui.desktop" } DEFINES += \ DEBUG_ENABLED \ I18N_DOMAIN=\\\"$${I18N_DOMAIN}\\\" RESOURCES += \ animationlabel.qrc \ http-warning.qrc SIGNONUI_DBUS_ADAPTORS += \ com.canonical.indicators.webcredentials.xml SIGNONUI_DBUS_INCLUDES += \ indicator-service.h include(signonui_dbus_adaptor.pri) po.target = ../po/signon-ui.pot po.depends = $${SOURCES} po.commands = xgettext -o $@ -d $${I18N_DOMAIN} --keyword=_ $^ QMAKE_EXTRA_TARGETS += \ po QMAKE_SUBSTITUTES += \ com.canonical.indicators.webcredentials.service.in \ com.nokia.singlesignonui.service.in service.path = $${INSTALL_PREFIX}/share/dbus-1/services service.files = \ com.canonical.indicators.webcredentials.service \ com.nokia.singlesignonui.service INSTALLS += service # Help file for HTTP authentication warning !isEmpty(HTTP_WARNING_HELP) { DEFINES += HTTP_WARNING_HELP=\\\"$${HTTP_WARNING_HELP}\\\" } ./src/debug.cpp0000644000015600001650000000156212701152050013453 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" int appLoggingLevel = 1; // criticals void setLoggingLevel(int level) { appLoggingLevel = level; } ./src/my-network-proxy-factory.cpp0000644000015600001650000001217712701152050017331 0ustar jenkinsjenkins/* * Copied from * https://codereview.qt-project.org/cat/29453%2C6%2Csrc/network/kernel/qnetworkproxy_libproxy.cpp%5E0 * * With minor modifications by * Alberto Mardegan */ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** This file may be used under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation and ** appearing in the file LICENSE.LGPL included in the packaging of this ** file. Please review the following information to ensure the GNU Lesser ** General Public License version 2.1 requirements will be met: ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General ** Public License version 3.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of this ** file. Please review the following information to ensure the GNU General ** Public License version 3.0 requirements will be met: ** http://www.gnu.org/copyleft/gpl.html. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "my-network-proxy-factory.h" #include #include #include #include class QLibProxyWrapper { public: QLibProxyWrapper() : factory(px_proxy_factory_new()) { } ~QLibProxyWrapper() { px_proxy_factory_free(factory); } QList getProxies(const QUrl &url); private: pxProxyFactory *factory; }; Q_GLOBAL_STATIC(QLibProxyWrapper, libProxyWrapper); /* Gets the list of proxies from libproxy, converted to QUrl list. Thread safe, according to libproxy documentation. */ QList QLibProxyWrapper::getProxies(const QUrl &url) { QList ret; if (factory) { char **proxies = px_proxy_factory_get_proxies(factory, url.toEncoded()); if (proxies) { for (int i = 0; proxies[i]; i++) { ret.append(QUrl::fromEncoded(proxies[i])); free(proxies[i]); } free(proxies); } } return ret; } QList MyNetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query) { QList proxyList; QUrl queryUrl; QNetworkProxy::Capabilities requiredCapabilities(0); switch (query.queryType()) { //URL requests are directly supported by libproxy case QNetworkProxyQuery::UrlRequest: queryUrl = query.url(); break; // fake URLs to get libproxy to tell us the SOCKS proxy case QNetworkProxyQuery::TcpSocket: queryUrl.setScheme(QLatin1String("tcp")); queryUrl.setHost(query.peerHostName()); queryUrl.setPort(query.peerPort()); requiredCapabilities |= QNetworkProxy::TunnelingCapability; break; case QNetworkProxyQuery::UdpSocket: queryUrl.setScheme(QLatin1String("udp")); queryUrl.setHost(query.peerHostName()); queryUrl.setPort(query.peerPort()); requiredCapabilities |= QNetworkProxy::UdpTunnelingCapability; break; default: proxyList.append(QNetworkProxy(QNetworkProxy::NoProxy)); return proxyList; } QList rawProxies = libProxyWrapper()->getProxies(queryUrl); bool haveDirectConnection = false; foreach (const QUrl& url, rawProxies) { QNetworkProxy::ProxyType type; if (url.scheme() == QLatin1String("http")) { type = QNetworkProxy::HttpProxy; } else if (url.scheme() == QLatin1String("socks") || url.scheme() == QLatin1String("socks5")) { type = QNetworkProxy::Socks5Proxy; } else if (url.scheme() == QLatin1String("ftp")) { type = QNetworkProxy::FtpCachingProxy; } else if (url.scheme() == QLatin1String("direct")) { type = QNetworkProxy::NoProxy; haveDirectConnection = true; } else { continue; //unsupported proxy type e.g. socks4 } QNetworkProxy proxy(type, url.host(), url.port(), url.userName(), url.password()); if ((proxy.capabilities() & requiredCapabilities) == requiredCapabilities) proxyList.append(proxy); } // fallback is direct connection if (proxyList.isEmpty() || !haveDirectConnection) proxyList.append(QNetworkProxy(QNetworkProxy::NoProxy)); return proxyList; } ./src/reauthenticator.h0000644000015600001650000000276012701152050015234 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_REAUTHENTICATOR_H #define SIGNON_UI_REAUTHENTICATOR_H #include #include #include namespace SignOnUi { struct AuthData { quint32 identity; QString method; QString mechanism; QVariantMap sessionData; }; class ReauthenticatorPrivate; class Reauthenticator: public QObject { Q_OBJECT public: Reauthenticator(const QList &clientData, const QVariantMap &extraParameters, QObject *parent = 0); ~Reauthenticator(); public Q_SLOTS: void start(); Q_SIGNALS: void finished(bool success); private: ReauthenticatorPrivate *d_ptr; Q_DECLARE_PRIVATE(Reauthenticator) }; } // namespace #endif // SIGNON_UI_REAUTHENTICATOR_H ./src/dialog-request.h0000644000015600001650000000261612701152050014760 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DIALOG_REQUEST_H #define SIGNON_UI_DIALOG_REQUEST_H #include "request.h" #include namespace SignOnUi { class DialogRequestPrivate; class DialogRequest: public Request { Q_OBJECT public: explicit DialogRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~DialogRequest(); // reimplemented virtual methods void start(); private: DialogRequestPrivate *d_ptr; Q_DECLARE_PRIVATE(DialogRequest) }; } // namespace #endif // SIGNON_UI_DIALOG_REQUEST_H ./src/i18n.h0000644000015600001650000000175412701152050012614 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_I18N_H #define SIGNON_UI_I18N_H #include namespace SignOnUi { void initTr(const char *domain, const char *localeDir); QString _(const char *text, const char *domain = 0); } // namespace #endif // SIGNON_UI_I18N_H ./src/browser-request.cpp0000644000015600001650000006035712701152050015545 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "browser-request.h" #include "animation-label.h" #include "cookie-jar-manager.h" #include "debug.h" #include "dialog.h" #include "http-warning.h" #include "i18n.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace SignOnUi; namespace SignOnUi { static const QString keyPreferredWidth = QString("PreferredWidth"); static const QString keyHorizontalScrollBar = QString("HorizontalScrollBar"); static const QString keyVerticalScrollBar = QString("VerticalScrollBar"); static const QString keyTextSizeMultiplier = QString("TextSizeMultiplier"); static const QString keyUserAgent = QString("UserAgent"); static const QString keyViewportWidth = QString("ViewportWidth"); static const QString keyViewportHeight = QString("ViewportHeight"); static const QString keyZoomFactor = QString("ZoomFactor"); static const QString keyUsernameField = QString("UsernameField"); static const QString keyPasswordField = QString("PasswordField"); static const QString keyLoginButton = QString("LoginButton"); static const QString keyInternalLinksPattern = QString("InternalLinksPattern"); static const QString keyExternalLinksPattern = QString("ExternalLinksPattern"); static const QString keyAllowedUrls = QString("AllowedUrls"); static const QString valueAlwaysOn = QString("alwaysOn"); static const QString valueAlwaysOff = QString("alwaysOff"); /* Additional session-data keys we support. */ static const QString keyCookies = QString("Cookies"); static const QString keyAllowedSchemes = QString("AllowedSchemes"); static const QString keyIgnoreSslErrors = QString("IgnoreSslErrors"); static bool pathsAreEqual(const QString &p1, const QString &p2) { static QRegExp regExp("/*$"); QString p1copy(p1); QString p2copy(p2); return p1copy.remove(regExp) == p2copy.remove(regExp); } class WebPage: public QWebPage { Q_OBJECT public: WebPage(QObject *parent = 0): QWebPage(parent) {} ~WebPage() {} void setUserAgent(const QString &userAgent) { m_userAgent = userAgent; } void setExternalLinksPattern(const QString &pattern) { m_externalLinksPattern = QRegExp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2); } void setInternalLinksPattern(const QString &pattern) { m_internalLinksPattern = QRegExp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2); } void setAllowedSchemes(const QStringList &schemes) { m_allowedSchemes = schemes; } void setAllowedUrls(const QString &pattern) { m_allowedUrls = QRegExp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2); } void setFinalUrl(const QUrl &url) { m_finalUrl = url; } protected: // reimplemented virtual methods QString userAgentForUrl(const QUrl &url) const { return m_userAgent.isEmpty() ? QWebPage::userAgentForUrl(url) : m_userAgent; } bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { Q_UNUSED(type); QUrl url = request.url(); TRACE() << url; /* We generally don't need to load the final URL, so skip loading it. * If this behaviour is not desired for some requests, then just avoid * calling setFinalUrl() */ if (url.host() == m_finalUrl.host() && pathsAreEqual(url.path(), m_finalUrl.path())) { Q_EMIT finalUrlReached(url); return false; } /* open all new window requests (identified by "frame == 0") in the * external browser, as well as other links according to the * ExternalLinksPattern and InternalLinksPattern rules. */ if (frame == 0 || urlIsBlocked(url)) { QDesktopServices::openUrl(url); return false; } /* Handle all other requests internally. */ return true; } Q_SIGNALS: void finalUrlReached(const QUrl &url); private: bool urlIsBlocked(QUrl url) const; private: QString m_userAgent; QRegExp m_externalLinksPattern; QRegExp m_internalLinksPattern; QStringList m_allowedSchemes; QRegExp m_allowedUrls; QUrl m_finalUrl; }; bool WebPage::urlIsBlocked(QUrl url) const { if (url == QUrl("about:blank")) return false; if (!m_allowedSchemes.contains(url.scheme())) { TRACE() << "Scheme not allowed:" << url.scheme(); return true; } if (!m_allowedUrls.isEmpty() && !m_allowedUrls.exactMatch(url.toString())) { TRACE() << "URL not allowed:" << url; return true; } QString urlText = url.toString(QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::RemoveFragment | QUrl::StripTrailingSlash); if (urlText.startsWith("//")) { urlText = urlText.mid(2); } if (!m_internalLinksPattern.isEmpty()) { return !m_internalLinksPattern.exactMatch(urlText); } if (!m_externalLinksPattern.isEmpty()) { return m_externalLinksPattern.exactMatch(urlText); } return false; } class WebView: public QWebView { Q_OBJECT public: WebView(QWidget *parent = 0): QWebView(parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setAttribute(Qt::WA_OpaquePaintEvent, true); } ~WebView() {}; void setPreferredSize(const QSize &size) { m_preferredSize = size; updateGeometry(); } protected: QSize sizeHint() const { if (m_preferredSize.isValid()) { return m_preferredSize; } else { return QSize(400, 300); } } void paintEvent(QPaintEvent *event) { QPainter painter(this); painter.fillRect(rect(), palette().window()); QWebView::paintEvent(event); } private: QSize m_preferredSize; }; class BrowserRequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(BrowserRequest) public: BrowserRequestPrivate(BrowserRequest *request); ~BrowserRequestPrivate(); QWidget *buildWebViewPage(const QVariantMap ¶ms); QWidget *buildSuccessPage(); QWidget *buildLoadFailurePage(); void buildDialog(const QVariantMap ¶ms); void start(); private Q_SLOTS: void onSslErrors(QNetworkReply *reply, const QList &errors); void onUrlChanged(const QUrl &url); void onLoadProgress(); void onLoadFinished(bool ok); void onFailTimer(); void onFinished(); void startProgress(); void stopProgress(); void onContentsChanged(); private: void showDialog(); void setupViewForUrl(const QUrl &url); void notifyAuthCompleted(); void notifyLoadFailed(); QWebElement initializeField(const QString &settingsKey, const QString ¶mKey = QString()); void initializeFields(); bool tryAutoLogin(); void addBrowserCookies(CookieJar *cookieJar); private: mutable BrowserRequest *q_ptr; /* The dialog can be deleted by the Request class, if it's set as children * of an embedded widget which is then deleted. Therefore, in order to * avoid a double deletion, guard the pointer with a QPointer. */ QPointer m_dialog; QStackedLayout *m_dialogLayout; QWidget *m_webViewPage; QWidget *m_successPage; QWidget *m_loadFailurePage; QStackedLayout *m_webViewLayout; WebView *m_webView; AnimationLabel *m_animationLabel; HttpWarning *m_httpWarning; QUrl finalUrl; QUrl responseUrl; QString m_host; QSettings *m_settings; QWebElement m_usernameField; QWebElement m_passwordField; QWebElement m_loginButton; QString m_username; QString m_password; int m_loginCount; bool m_ignoreSslErrors; QTimer m_failTimer; }; } // namespace BrowserRequestPrivate::BrowserRequestPrivate(BrowserRequest *request): QObject(request), q_ptr(request), m_dialog(0), m_webViewLayout(0), m_webView(0), m_animationLabel(0), m_httpWarning(0), m_settings(0), m_loginCount(0), m_ignoreSslErrors(false) { m_failTimer.setSingleShot(true); m_failTimer.setInterval(3000); QObject::connect(&m_failTimer, SIGNAL(timeout()), this, SLOT(onFailTimer())); } BrowserRequestPrivate::~BrowserRequestPrivate() { delete m_dialog; } void BrowserRequestPrivate::onSslErrors(QNetworkReply *reply, const QList &errors) { TRACE() << errors; if (m_ignoreSslErrors) { reply->ignoreSslErrors(); } } void BrowserRequestPrivate::onUrlChanged(const QUrl &url) { Q_Q(BrowserRequest); TRACE() << "Url changed:" << url; m_failTimer.stop(); if (url.host() == finalUrl.host() && pathsAreEqual(url.path(), finalUrl.path())) { responseUrl = url; if (q->embeddedUi() || !m_dialog->isVisible()) { /* Do not show the notification page. */ m_dialog->accept(); } else { /* Replace the web page with an information screen */ notifyAuthCompleted(); } } setupViewForUrl(url); m_httpWarning->setVisible(url.scheme() == "http"); } void BrowserRequestPrivate::onLoadProgress() { m_failTimer.stop(); } void BrowserRequestPrivate::onLoadFinished(bool ok) { TRACE() << "Load finished" << ok; if (!ok) { m_failTimer.start(); return; } if (loggingLevel() > 2) { /* Dump the HTML */ TRACE() << m_webView->page()->mainFrame()->toHtml(); } initializeFields(); if (!m_dialog->isVisible()) { if (responseUrl.isEmpty()) { if (!tryAutoLogin()) showDialog(); } else { onFinished(); } } } void BrowserRequestPrivate::onFailTimer() { notifyLoadFailed(); } void BrowserRequestPrivate::addBrowserCookies(CookieJar *cookieJar) { Q_Q(BrowserRequest); const QVariantMap &clientData = q->clientData(); if (!clientData.contains(keyCookies)) return; RawCookies rawCookies; QDBusArgument arg = clientData[keyCookies].value(); if (arg.currentSignature() == "a{sv}") { /* The signature of the argument should be "a{ss}", not "a{sv}"; * however, ruby-dbus is rather primitive and there seems to be no way * to speficy a different signature than "a{sv}" when marshalling Hash * into a variant. * Therefore, just for our functional tests, also support "a{sv}". */ QVariantMap cookieMap = qdbus_cast(arg); QVariantMap::const_iterator i; for (i = cookieMap.constBegin(); i != cookieMap.constEnd(); i++) { rawCookies.insert(i.key(), i.value().toString()); } } else { rawCookies = qdbus_cast(arg); } QList cookies; RawCookies::const_iterator i; for (i = rawCookies.constBegin(); i != rawCookies.constEnd(); i++) { cookies.append(QNetworkCookie::parseCookies(i.value().toUtf8())); } TRACE() << "cookies:" << cookies; cookieJar->setCookies(cookies); } void BrowserRequestPrivate::startProgress() { m_animationLabel->start(); m_webViewLayout->setCurrentIndex(1); } void BrowserRequestPrivate::stopProgress() { m_animationLabel->stop(); m_webViewLayout->setCurrentIndex(0); } QWidget *BrowserRequestPrivate::buildWebViewPage(const QVariantMap ¶ms) { Q_Q(BrowserRequest); QWidget *dialogPage = new QWidget; m_webViewLayout = new QStackedLayout(dialogPage); m_webView = new WebView(); WebPage *page = new WebPage(this); QObject::connect(page, SIGNAL(contentsChanged()), this, SLOT(onContentsChanged())); QObject::connect(page->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,const QList &)), this, SLOT(onSslErrors(QNetworkReply*,const QList &))); m_webView->setPage(page); /* The following couple of lines serve to instruct the QWebPage not to load * the final URL, but to block it and emit the finalUrlReached() signal * instead. */ page->setFinalUrl(finalUrl); QObject::connect(page, SIGNAL(finalUrlReached(const QUrl&)), this, SLOT(onUrlChanged(const QUrl&))); /* set a per-identity cookie jar on the page */ uint identity = q->identity(); CookieJarManager *cookieJarManager = CookieJarManager::instance(); CookieJar *cookieJar = cookieJarManager->cookieJarForIdentity(identity); addBrowserCookies(cookieJar); page->networkAccessManager()->setCookieJar(cookieJar); /* NetworkAccessManager takes ownership of the cookieJar; we don't want * this */ cookieJar->setParent(cookieJarManager); const QVariantMap &clientData = q->clientData(); if (clientData.contains(keyAllowedSchemes)) { page->setAllowedSchemes(clientData[keyAllowedSchemes].toStringList()); } else { /* by default, allow only https */ page->setAllowedSchemes(QStringList("https")); } m_ignoreSslErrors = clientData.value(keyIgnoreSslErrors, false).toBool(); QUrl url(params.value(SSOUI_KEY_OPENURL).toString()); setupViewForUrl(url); QObject::connect(m_webView, SIGNAL(urlChanged(const QUrl&)), this, SLOT(onUrlChanged(const QUrl&))); QObject::connect(m_webView, SIGNAL(loadProgress(int)), this, SLOT(onLoadProgress())); QObject::connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); QWidget *webViewContainer = new QWidget; QVBoxLayout *vLayout = new QVBoxLayout; vLayout->setSpacing(0); webViewContainer->setLayout(vLayout); vLayout->addWidget(m_webView); m_httpWarning = new HttpWarning; m_httpWarning->setVisible(false); vLayout->addWidget(m_httpWarning); m_webViewLayout->addWidget(webViewContainer); m_animationLabel = new AnimationLabel(":/spinner-26.gif", 0); QObject::connect(m_webView, SIGNAL(loadStarted()), this, SLOT(startProgress())); QObject::connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(stopProgress())); m_webViewLayout->addWidget(m_animationLabel); m_webView->setUrl(url); return dialogPage; } QWidget *BrowserRequestPrivate::buildSuccessPage() { QWidget *dialogPage = new QWidget; dialogPage->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::MinimumExpanding); QVBoxLayout *layout = new QVBoxLayout(dialogPage); QLabel *label = new QLabel(_("The authentication process is complete.\n" "You may now close this dialog " "and return to the application.")); label->setAlignment(Qt::AlignCenter); layout->addWidget(label); QPushButton *doneButton = new QPushButton(_("Done")); doneButton->setDefault(true); QObject::connect(doneButton, SIGNAL(clicked()), m_dialog, SLOT(accept())); layout->addWidget(doneButton); return dialogPage; } QWidget *BrowserRequestPrivate::buildLoadFailurePage() { QWidget *dialogPage = new QWidget; dialogPage->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::MinimumExpanding); QVBoxLayout *layout = new QVBoxLayout(dialogPage); QLabel *label = new QLabel(_("An error occurred while loading " "the authentication page.")); label->setAlignment(Qt::AlignCenter); layout->addWidget(label); return dialogPage; } void BrowserRequestPrivate::buildDialog(const QVariantMap ¶ms) { m_dialog = new Dialog; QString title; if (params.contains(SSOUI_KEY_TITLE)) { title = params[SSOUI_KEY_TITLE].toString(); } else if (params.contains(SSOUI_KEY_CAPTION)) { title = _("Web authentication for %1"). arg(params[SSOUI_KEY_CAPTION].toString()); } else { title = _("Web authentication"); } m_dialog->setWindowTitle(title); m_dialogLayout = new QStackedLayout(m_dialog); m_webViewPage = buildWebViewPage(params); m_dialogLayout->addWidget(m_webViewPage); m_successPage = buildSuccessPage(); m_dialogLayout->addWidget(m_successPage); m_loadFailurePage = buildLoadFailurePage(); m_dialogLayout->addWidget(m_loadFailurePage); TRACE() << "Dialog was built"; } void BrowserRequestPrivate::start() { Q_Q(BrowserRequest); finalUrl = QUrl(q->parameters().value(SSOUI_KEY_FINALURL).toString()); buildDialog(q->parameters()); QObject::connect(m_dialog, SIGNAL(finished(int)), this, SLOT(onFinished())); if (q->embeddedUi()) { showDialog(); } } void BrowserRequestPrivate::onFinished() { Q_Q(BrowserRequest); TRACE() << "Browser dialog closed"; QObject::disconnect(m_webView, 0, this, 0); QVariantMap reply; QUrl url = responseUrl.isEmpty() ? m_webView->url() : responseUrl; reply[SSOUI_KEY_URLRESPONSE] = url.toString(); if (!m_username.isEmpty()) reply[SSOUI_KEY_USERNAME] = m_username; if (!m_password.isEmpty()) reply[SSOUI_KEY_PASSWORD] = m_password; q->setResult(reply); } void BrowserRequestPrivate::onContentsChanged() { /* See https://bugs.webkit.org/show_bug.cgi?id=32865 for the reason why * we are not simply calling m_usernameField.attribute("value") */ if (!m_usernameField.isNull()) { m_username = m_usernameField.evaluateJavaScript("this.value").toString(); } if (!m_passwordField.isNull()) { m_password = m_passwordField.evaluateJavaScript("this.value").toString(); } } void BrowserRequestPrivate::showDialog() { Q_Q(BrowserRequest); q->setWidget(m_dialog); } static Qt::ScrollBarPolicy scrollPolicyFromValue(const QVariant &value) { QString stringValue = value.toString(); if (stringValue == valueAlwaysOn) { return Qt::ScrollBarAlwaysOn; } else if (stringValue == valueAlwaysOff) { return Qt::ScrollBarAlwaysOff; } else { return Qt::ScrollBarAsNeeded; } } void BrowserRequestPrivate::setupViewForUrl(const QUrl &url) { QString host = url.host(); if (host == m_host) return; m_host = host; /* Load the host-specific configuration file */ delete m_settings; m_settings = new QSettings("signon-ui/webkit-options.d/" + host, QString(), this); WebPage *page = qobject_cast(m_webView->page()); if (m_settings->contains(keyViewportWidth) && m_settings->contains(keyViewportHeight)) { QSize viewportSize(m_settings->value(keyViewportWidth).toInt(), m_settings->value(keyViewportHeight).toInt()); m_webView->setPreferredSize(viewportSize); } if (m_settings->contains(keyPreferredWidth)) { QSize preferredSize(m_settings->value(keyPreferredWidth).toInt(), 300); page->setPreferredContentsSize(preferredSize); } if (m_settings->contains(keyTextSizeMultiplier)) { m_webView->setTextSizeMultiplier(m_settings->value(keyTextSizeMultiplier). toReal()); } if (m_settings->contains(keyUserAgent)) { page->setUserAgent(m_settings->value(keyUserAgent).toString()); } if (m_settings->contains(keyZoomFactor)) { m_webView->setZoomFactor(m_settings->value(keyZoomFactor).toReal()); } if (m_settings->contains(keyHorizontalScrollBar)) { Qt::ScrollBarPolicy policy = scrollPolicyFromValue(m_settings->value(keyHorizontalScrollBar)); page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, policy); } if (m_settings->contains(keyVerticalScrollBar)) { Qt::ScrollBarPolicy policy = scrollPolicyFromValue(m_settings->value(keyVerticalScrollBar)); page->mainFrame()->setScrollBarPolicy(Qt::Vertical, policy); } page->setExternalLinksPattern(m_settings->value(keyExternalLinksPattern). toString()); page->setInternalLinksPattern(m_settings->value(keyInternalLinksPattern). toString()); page->setAllowedUrls(m_settings->value(keyAllowedUrls).toString()); } void BrowserRequestPrivate::notifyAuthCompleted() { /* Ignore any webview signals from now on. * This is needed because QWebView might still emit loadFinished(false) * (which we would interpret as an error) on the final URL, which we don't * care about anymore. */ QObject::disconnect(m_webView, 0, this, 0); m_dialogLayout->setCurrentWidget(m_successPage); } void BrowserRequestPrivate::notifyLoadFailed() { m_dialogLayout->setCurrentWidget(m_loadFailurePage); showDialog(); } QWebElement BrowserRequestPrivate::initializeField(const QString &settingsKey, const QString ¶mKey) { Q_Q(BrowserRequest); QWebElement element; if (!m_settings->contains(settingsKey)) return element; QString selector = m_settings->value(settingsKey).toString(); if (selector.isEmpty()) return element; QWebFrame *frame = m_webView->page()->mainFrame(); element = frame->findFirstElement(selector); if (!element.isNull()) { const QVariantMap ¶ms = q->parameters(); if (!paramKey.isEmpty() && params.contains(paramKey)) { QString value = params.value(paramKey).toString(); if (!value.isEmpty()) { element.setAttribute("value", value); } } } else { BLAME() << "Couldn't find element:" << selector; } return element; } void BrowserRequestPrivate::initializeFields() { /* If the configuration file contains a "UsernameField" or a * "PasswordField" key whose value is set to a valid CSS selector, we get * the QWebElement to these fields. * Also, if the username or password are present in the input parameters, * we prefill the respective fields. */ m_usernameField = initializeField(keyUsernameField, SSOUI_KEY_USERNAME); m_passwordField = initializeField(keyPasswordField, SSOUI_KEY_PASSWORD); m_loginButton = initializeField(keyLoginButton); } bool BrowserRequestPrivate::tryAutoLogin() { if (m_loginButton.isNull()) return false; if (m_usernameField.isNull() || m_usernameField.evaluateJavaScript("this.value").isNull()) return false; if (m_passwordField.isNull() || m_passwordField.evaluateJavaScript("this.value").isNull()) return false; /* Avoid falling in a failed login loop */ m_loginCount++; if (m_loginCount > 1) return false; m_loginButton.evaluateJavaScript("this.click()"); return true; } BrowserRequest::BrowserRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): Request(connection, message, parameters, parent), d_ptr(new BrowserRequestPrivate(this)) { } BrowserRequest::~BrowserRequest() { } void BrowserRequest::start() { Q_D(BrowserRequest); Request::start(); d->start(); } #include "browser-request.moc" ./src/webcredentials_interface.h0000644000015600001650000000407612701152050017050 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #define SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #include #include #include #include #include #include #include #include namespace SignOnUi { class IndicatorService; }; /* * Proxy class for interface com.canonical.indicators.webcredentials */ class ComCanonicalIndicatorsWebcredentialsInterface: public QObject { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.canonical.indicators.webcredentials"; } public: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~ComCanonicalIndicatorsWebcredentialsInterface(); QDBusPendingReply<> ReportFailure(uint account_id, const QVariantMap ¬ification); Q_SIGNALS: // SIGNALS }; namespace com { namespace canonical { namespace indicators { typedef ::ComCanonicalIndicatorsWebcredentialsInterface webcredentials; } } } #endif // SIGNON_UI_WEBCREDENTIALS_INTERFACE_H ./src/com.canonical.indicators.webcredentials.service.in0000644000015600001650000000040012701152050023472 0ustar jenkinsjenkins[D-BUS Service] Name=com.canonical.indicators.webcredentials Exec=/bin/sh -c "'if [ ! -x $${target.path}/$${TARGET} ] || [ \"$QT_QPA_PLATFORM\" = \"ubuntumirclient\" ]; then exec /usr/bin/online-accounts-service; else exec $${target.path}/$${TARGET}; fi'" ./src/remote-request-interface.cpp0000644000015600001650000002071012701152050017300 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "remote-request-interface.h" #include "debug.h" #include #include #include #include using namespace SignOnUi; namespace SignOnUi { static const QByteArray welcomeMessage = "SsoUi"; class IpcHandler: public QObject { Q_OBJECT public: enum Code { Start = 1, Cancel, SetResult, SetCanceled, }; IpcHandler(); ~IpcHandler(); void setChannels(QIODevice *readChannel, QIODevice *writeChannel); void write(const QByteArray &data); Q_SIGNALS: void dataReady(const QByteArray &data); private Q_SLOTS: void onReadyRead(); private: bool waitWelcomeMessage(); private: QIODevice *m_readChannel; QIODevice *m_writeChannel; int m_expectedLength; bool m_gotWelcomeMessage; QByteArray m_readBuffer; }; } // namespace IpcHandler::IpcHandler(): QObject(), m_readChannel(0), m_writeChannel(0), m_expectedLength(0), m_gotWelcomeMessage(false) { } IpcHandler::~IpcHandler() { } void IpcHandler::setChannels(QIODevice *readChannel, QIODevice *writeChannel) { m_readChannel = readChannel; m_writeChannel = writeChannel; QObject::connect(m_readChannel, SIGNAL(readyRead()), this, SLOT(onReadyRead())); /* QFile need special handling */ QFile *file = qobject_cast(m_readChannel); if (file != 0) { QSocketNotifier *notifier = new QSocketNotifier(file->handle(), QSocketNotifier::Read, this); QObject::connect(notifier, SIGNAL(activated(int)), this, SLOT(onReadyRead())); } onReadyRead(); if (m_writeChannel != 0) { m_writeChannel->write(welcomeMessage); } } void IpcHandler::write(const QByteArray &data) { int length = data.count(); m_writeChannel->write((char *)&length, sizeof(length)); m_writeChannel->write(data); } void IpcHandler::onReadyRead() { while (true) { if (m_expectedLength == 0) { /* We are beginning a new read */ /* skip all noise */ if (!waitWelcomeMessage()) break; int length; int bytesRead = m_readChannel->read((char *)&length, sizeof(length)); if (bytesRead < int(sizeof(length))) break; m_expectedLength = length; m_readBuffer.clear(); } int neededBytes = m_expectedLength - m_readBuffer.length(); QByteArray buffer = m_readChannel->read(neededBytes); m_readBuffer += buffer; if (buffer.length() < neededBytes) break; if (m_readBuffer.length() == m_expectedLength) { Q_EMIT dataReady(m_readBuffer); m_expectedLength = 0; } } } bool IpcHandler::waitWelcomeMessage() { if (m_gotWelcomeMessage) return true; /* All Qt applications on the Nexus 4 write some just to stdout when * starting. So, skip all input until a well-defined welcome message is * found */ QByteArray buffer; int startCheckIndex = 0; do { buffer = m_readChannel->peek(40); int found = buffer.indexOf(welcomeMessage, startCheckIndex); int skip = (found >= 0) ? found : buffer.length() - welcomeMessage.length(); if (found >= 0) { buffer = m_readChannel->read(skip + welcomeMessage.length()); m_gotWelcomeMessage = true; return true; } if (skip > 0) { buffer = m_readChannel->read(skip); } else { buffer.clear(); } } while (!buffer.isEmpty()); return false; } namespace SignOnUi { class RemoteRequestClientPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(RemoteRequestClient) public: RemoteRequestClientPrivate(RemoteRequestClient *client); ~RemoteRequestClientPrivate() {}; private Q_SLOTS: void onDataReady(const QByteArray &data); private: IpcHandler m_handler; mutable RemoteRequestClient *q_ptr; }; } // namespace RemoteRequestClientPrivate::RemoteRequestClientPrivate(RemoteRequestClient *client): QObject(client), q_ptr(client) { QObject::connect(&m_handler, SIGNAL(dataReady(const QByteArray&)), this, SLOT(onDataReady(const QByteArray&))); } void RemoteRequestClientPrivate::onDataReady(const QByteArray &data) { Q_Q(RemoteRequestClient); QDataStream dataStream(data); // All messages start with the operation code int code; dataStream >> code; if (code == IpcHandler::SetResult) { QVariantMap result; dataStream >> result; Q_EMIT q->result(result); } else if (code == IpcHandler::SetCanceled) { Q_EMIT q->canceled(); } else { qWarning() << "Unsupported opcode" << code; } } RemoteRequestClient::RemoteRequestClient(QObject *parent): QObject(parent), d_ptr(new RemoteRequestClientPrivate(this)) { } RemoteRequestClient::~RemoteRequestClient() { } void RemoteRequestClient::setChannels(QIODevice *readChannel, QIODevice *writeChannel) { Q_D(RemoteRequestClient); d->m_handler.setChannels(readChannel, writeChannel); } void RemoteRequestClient::start(const QVariantMap ¶meters) { Q_D(RemoteRequestClient); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::Start); dataStream << parameters; d->m_handler.write(data); } void RemoteRequestClient::cancel() { Q_D(RemoteRequestClient); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::Cancel); d->m_handler.write(data); } namespace SignOnUi { class RemoteRequestServerPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(RemoteRequestServer) public: RemoteRequestServerPrivate(RemoteRequestServer *server); ~RemoteRequestServerPrivate() {}; private Q_SLOTS: void onDataReady(const QByteArray &data); private: IpcHandler m_handler; mutable RemoteRequestServer *q_ptr; }; } // namespace RemoteRequestServerPrivate::RemoteRequestServerPrivate(RemoteRequestServer *server): QObject(server), q_ptr(server) { QObject::connect(&m_handler, SIGNAL(dataReady(const QByteArray&)), this, SLOT(onDataReady(const QByteArray&))); } void RemoteRequestServerPrivate::onDataReady(const QByteArray &data) { Q_Q(RemoteRequestServer); QDataStream dataStream(data); // All messages start with the operation code int code; dataStream >> code; if (code == IpcHandler::Start) { QVariantMap parameters; dataStream >> parameters; Q_EMIT q->started(parameters); } else if (code == IpcHandler::Cancel) { Q_EMIT q->canceled(); } else { qWarning() << "Unsupported opcode" << code; } } RemoteRequestServer::RemoteRequestServer(QObject *parent): QObject(parent), d_ptr(new RemoteRequestServerPrivate(this)) { } RemoteRequestServer::~RemoteRequestServer() { } void RemoteRequestServer::setChannels(QIODevice *readChannel, QIODevice *writeChannel) { Q_D(RemoteRequestServer); d->m_handler.setChannels(readChannel, writeChannel); } void RemoteRequestServer::setResult(const QVariantMap &result) { Q_D(RemoteRequestServer); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::SetResult); dataStream << result; d->m_handler.write(data); } void RemoteRequestServer::setCanceled() { Q_D(RemoteRequestServer); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::SetCanceled); d->m_handler.write(data); } #include "remote-request-interface.moc" ./src/security-low.png0000644000015600001650000000075312701152050015036 0ustar jenkinsjenkins‰PNG  IHDRóÿasBIT|dˆ pHYs × ×B(›xtEXtSoftwarewww.inkscape.org›î<hIDAT8u±JA†¿½xäPPSؤ‰¦Ðg| KL­9¸f.UbR"°±·P{ñ|;!…H@Sáv-܄͙X–™ÿÛF´Z­­u¨«@|O@CDž­õ%p¬[qœ[¥R©ômËÀ0X°ÉZá—^·Zë›<ÏŽœ:=›}¬C­õ°mÏ50,ô¬¹€Ð­ˆÈ PwRÀkPvÅ0€òÔfb ”: ðj](¥TlKù ðêäþŒ1ƒ$IFiš61m+Ž’$EQtáˆHæÀ*ÖÕØíɲìÓ àoö ,RcL[DÄÉkWà["ö÷‰£È×SL7?oÖÁŒfòø±ÅòtÏ€E{»€wÛ|Øív—,,:Ƙvš¦M€~¿_VJYÍÛÔ²ˆ<»¾9=ñ "û'À=P´;/ÆÀÐø¦@}-›DéIEND®B`‚./src/embed-manager.h0000644000015600001650000000233612701152050014516 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_EMBED_H #define SIGNON_UI_EMBED_H #include #include namespace SignOnUi { class EmbedManagerPrivate; class EmbedManager: public QObject { Q_OBJECT public: static EmbedManager *instance(); ~EmbedManager(); QX11EmbedWidget *widgetFor(WId windowId); public: EmbedManager(QObject *parent = 0); private: EmbedManagerPrivate *d_ptr; Q_DECLARE_PRIVATE(EmbedManager) }; } // namespace #endif // SIGNON_UI_EMBED_H ./src/request.h0000644000015600001650000000430012701152050013513 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_REQUEST_H #define SIGNON_UI_REQUEST_H #include #include #include #include #include namespace SignOnUi { class RequestPrivate; class Request: public QObject { Q_OBJECT public: static Request *newRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~Request(); static QString id(const QVariantMap ¶meters); QString id() const; uint identity() const; QString method() const; QString mechanism() const; WId windowId() const; bool embeddedUi() const; bool isInProgress() const; const QVariantMap ¶meters() const; const QVariantMap &clientData() const; public Q_SLOTS: virtual void start(); void cancel(); Q_SIGNALS: void completed(); protected: explicit Request(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); void setWidget(QWidget *widget); protected Q_SLOTS: void fail(const QString &name, const QString &message); void setCanceled(); void setResult(const QVariantMap &result); private: RequestPrivate *d_ptr; Q_DECLARE_PRIVATE(Request) }; } // namespace #endif // SIGNON_UI_REQUEST_H ./src/http-warning.cpp0000644000015600001650000000410212701152050015000 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "http-warning.h" #include "debug.h" #include "i18n.h" #include #include #include #include #include using namespace SignOnUi; HttpWarning::HttpWarning(QWidget *parent): QWidget(parent) { QVBoxLayout *vLayout = new QVBoxLayout; vLayout->setContentsMargins(0, 0, 0, 0); setLayout(vLayout); QFrame *separator = new QFrame; separator->setFrameShape(QFrame::HLine); separator->setFrameShadow(QFrame::Raised); separator->setContentsMargins(0, 0, 0, 0); vLayout->addWidget(separator); QWidget *labels = new QWidget; vLayout->addWidget(labels); QHBoxLayout *labelsLayout = new QHBoxLayout; labelsLayout->setContentsMargins(0, 0, 0, 0); labels->setLayout(labelsLayout); QLabel *label = new QLabel; label->setPixmap(QPixmap(":security-low.png")); labelsLayout->addWidget(label); label = new QLabel; label->setTextFormat(Qt::RichText); QString text = _("This site uses an insecure connection."); #ifdef HTTP_WARNING_HELP text.append(QString(" %1"). arg(_("What does this mean?"))); #endif label->setText(text); label->setOpenExternalLinks(true); labelsLayout->addWidget(label); labelsLayout->addStretch(); } HttpWarning::~HttpWarning() { } ./src/com.nokia.singlesignonui.service.in0000644000015600001650000000036112701152050020556 0ustar jenkinsjenkins[D-BUS Service] Name=com.nokia.singlesignonui Exec=/bin/sh -c "'if [ ! -x $${target.path}/$${TARGET} ] || [ \"$QT_QPA_PLATFORM\" = \"ubuntumirclient\" ]; then exec /usr/bin/online-accounts-service; else exec $${target.path}/$${TARGET}; fi'" ./src/http-warning.qrc0000644000015600001650000000013012701152050015000 0ustar jenkinsjenkins security-low.png ./src/src.pro0000644000015600001650000000012212701152050013161 0ustar jenkinsjenkinsinclude(../common-project-config.pri) TEMPLATE = subdirs SUBDIRS = signon-ui.pro ./src/inactivity-timer.cpp0000644000015600001650000000332312701152050015663 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "inactivity-timer.h" #include "debug.h" using namespace SignOnUi; InactivityTimer::InactivityTimer(int interval, QObject *parent): QObject(parent), m_interval(interval) { m_timer.setSingleShot(true); QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimeout())); } void InactivityTimer::watchObject(QObject *object) { connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged())); m_watchedObjects.append(object); /* Force an initial check */ onIdleChanged(); } void InactivityTimer::onIdleChanged() { if (allObjectsAreIdle()) { m_timer.start(m_interval); } } void InactivityTimer::onTimeout() { TRACE(); if (allObjectsAreIdle()) { Q_EMIT timeout(); } } bool InactivityTimer::allObjectsAreIdle() const { foreach (const QObject *object, m_watchedObjects) { if (!object->property("isIdle").toBool()) { return false; } } return true; } ./src/ubuntu-browser-request.cpp0000644000015600001650000001677212701152055017074 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "ubuntu-browser-request.h" #include "debug.h" #include "qquick-dialog.h" #include "errors.h" #include "i18n.h" #include #include #include #include #include using namespace SignOnUi; using namespace SignOnUi::QQuick; namespace SignOnUi { class UbuntuBrowserRequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(UbuntuBrowserRequest) Q_PROPERTY(QUrl pageComponentUrl READ pageComponentUrl CONSTANT) Q_PROPERTY(QUrl currentUrl READ currentUrl WRITE setCurrentUrl) Q_PROPERTY(QUrl startUrl READ startUrl CONSTANT) Q_PROPERTY(QUrl finalUrl READ finalUrl CONSTANT) public: UbuntuBrowserRequestPrivate(UbuntuBrowserRequest *request); ~UbuntuBrowserRequestPrivate(); void start(); void setCurrentUrl(const QUrl &url); QUrl pageComponentUrl() const; QUrl currentUrl() const { return m_currentUrl; } QUrl startUrl() const { return m_startUrl; } QUrl finalUrl() const { return m_finalUrl; } QUrl responseUrl() const { return m_responseUrl; } public Q_SLOTS: void cancel(); void onLoadStarted(); void onLoadFinished(bool ok); private Q_SLOTS: void onFailTimer(); void onFinished(); private: void buildDialog(const QVariantMap ¶ms); private: Dialog *m_dialog; QUrl m_currentUrl; QUrl m_startUrl; QUrl m_finalUrl; QUrl m_responseUrl; QTimer m_failTimer; mutable UbuntuBrowserRequest *q_ptr; }; } // namespace UbuntuBrowserRequestPrivate::UbuntuBrowserRequestPrivate( UbuntuBrowserRequest *request): QObject(request), m_dialog(0), q_ptr(request) { m_failTimer.setSingleShot(true); m_failTimer.setInterval(3000); QObject::connect(&m_failTimer, SIGNAL(timeout()), this, SLOT(onFailTimer())); } UbuntuBrowserRequestPrivate::~UbuntuBrowserRequestPrivate() { delete m_dialog; } void UbuntuBrowserRequestPrivate::start() { Q_Q(UbuntuBrowserRequest); const QVariantMap ¶ms = q->parameters(); TRACE() << params; QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); QDir rootDir = cachePath + QString("/id-%1").arg(q->identity()); if (!rootDir.exists()) { rootDir.mkpath("."); } m_finalUrl = params.value(SSOUI_KEY_FINALURL).toString(); m_startUrl = params.value(SSOUI_KEY_OPENURL).toString(); buildDialog(params); QObject::connect(m_dialog, SIGNAL(finished(int)), this, SLOT(onFinished())); QUrl webview("qrc:/MainWindow.qml"); QDir qmlDir("/usr/share/signon-ui/qml"); if (qmlDir.exists()) { QFileInfo qmlFile(qmlDir.absolutePath() + "/MainWindow.qml"); if (qmlFile.exists()) webview.setUrl(qmlFile.absoluteFilePath()); } m_dialog->rootContext()->setContextProperty("request", this); m_dialog->rootContext()->setContextProperty("rootDir", QUrl::fromLocalFile(rootDir.absolutePath())); m_dialog->setSource(webview); } QUrl UbuntuBrowserRequestPrivate::pageComponentUrl() const { Q_Q(const UbuntuBrowserRequest); /* We define the X-PageComponent key to let the clients override the QML * component to be used to build the authentication page. * To prevent a malicious client to show it's own UI, we require that the * file path begins with "/usr/share/signon-ui/" (where Ubuntu click * packages cannot install files). */ QUrl providedUrl = q->clientData().value("X-PageComponent").toString(); if (providedUrl.isValid() && providedUrl.isLocalFile() && providedUrl.path().startsWith("/usr/share/signon-ui/")) { return providedUrl; } else { return QStringLiteral("DefaultPage.qml"); } } void UbuntuBrowserRequestPrivate::setCurrentUrl(const QUrl &url) { TRACE() << "Url changed:" << url; m_failTimer.stop(); if (url.host() == m_finalUrl.host() && url.path() == m_finalUrl.path()) { m_responseUrl = url; if (!m_dialog->isVisible()) { /* Do not show the notification page. */ m_dialog->accept(); } else { /* Replace the web page with an information screen */ /* TODO */ m_dialog->accept(); } } } void UbuntuBrowserRequestPrivate::cancel() { Q_Q(UbuntuBrowserRequest); TRACE() << "Client requested to cancel"; q->setCanceled(); if (m_dialog) { m_dialog->close(); } } void UbuntuBrowserRequestPrivate::onLoadStarted() { m_failTimer.stop(); } void UbuntuBrowserRequestPrivate::onLoadFinished(bool ok) { Q_Q(const UbuntuBrowserRequest); TRACE() << "Load finished" << ok; if (!ok) { m_failTimer.start(); return; } if (!m_dialog->isVisible()) { if (m_responseUrl.isEmpty()) { Dialog::ShowMode mode = (q->windowId() == 0) ? Dialog::TopLevel : q->embeddedUi() ? Dialog::Embedded : Dialog::Transient; m_dialog->show(q->windowId(), mode); } else { onFinished(); } } } void UbuntuBrowserRequestPrivate::onFailTimer() { Q_Q(UbuntuBrowserRequest); TRACE() << "Page loading failed"; if (m_dialog) { m_dialog->close(); } q->setResult(QVariantMap()); } void UbuntuBrowserRequestPrivate::onFinished() { Q_Q(UbuntuBrowserRequest); TRACE() << "Browser dialog closed"; QObject::disconnect(m_dialog, SIGNAL(finished(int)), this, SLOT(onFinished())); QVariantMap reply; QUrl url = m_responseUrl.isEmpty() ? m_currentUrl : m_responseUrl; reply[SSOUI_KEY_URLRESPONSE] = url.toString(); m_dialog->close(); q->setResult(reply); } void UbuntuBrowserRequestPrivate::buildDialog(const QVariantMap ¶ms) { m_dialog = new Dialog; QString title; if (params.contains(SSOUI_KEY_TITLE)) { title = params[SSOUI_KEY_TITLE].toString(); } else if (params.contains(SSOUI_KEY_CAPTION)) { title = _("Web authentication for %1"). arg(params[SSOUI_KEY_CAPTION].toString()); } else { title = _("Web authentication"); } m_dialog->setTitle(title); TRACE() << "Dialog was built"; } UbuntuBrowserRequest::UbuntuBrowserRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): Request(connection, message, parameters, parent), d_ptr(new UbuntuBrowserRequestPrivate(this)) { } UbuntuBrowserRequest::~UbuntuBrowserRequest() { } void UbuntuBrowserRequest::start() { Q_D(UbuntuBrowserRequest); Request::start(); d->start(); } #include "ubuntu-browser-request.moc" ./src/service.h0000644000015600001650000000311712701152050013470 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_SERVICE_H #define SIGNON_UI_SERVICE_H #include #include #include namespace SignOnUi { class ServicePrivate; class Service: public QObject, protected QDBusContext { Q_OBJECT Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) Q_CLASSINFO("D-Bus Interface", "com.nokia.singlesignonui") public: explicit Service(QObject *parent = 0); ~Service(); bool isIdle() const; public Q_SLOTS: QVariantMap queryDialog(const QVariantMap ¶meters); QVariantMap refreshDialog(const QVariantMap &newParameters); Q_NOREPLY void cancelUiRequest(const QString &requestId); void removeIdentityData(quint32 id); Q_SIGNALS: void isIdleChanged(); private: ServicePrivate *d_ptr; Q_DECLARE_PRIVATE(Service) }; } // namespace #endif // SIGNON_UI_SERVICE_H ./src/indicator-service.h0000644000015600001650000000355612701152050015451 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_INDICATOR_SERVICE_H #define SIGNON_UI_INDICATOR_SERVICE_H #include #include #include namespace SignOnUi { #define WEBCREDENTIALS_OBJECT_PATH "/com/canonical/indicators/webcredentials" #define WEBCREDENTIALS_INTERFACE "com.canonical.indicators.webcredentials" #define WEBCREDENTIALS_BUS_NAME WEBCREDENTIALS_INTERFACE class IndicatorServicePrivate; class IndicatorService: public QObject { Q_OBJECT Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) public: explicit IndicatorService(QObject *parent = 0); ~IndicatorService(); static IndicatorService *instance(); QObject *serviceObject() const; void clearErrorStatus(); void removeFailures(const QSet &accountIds); void reportFailure(uint accountId, const QVariantMap ¬ification); QSet failures() const; bool errorStatus() const; bool isIdle() const; Q_SIGNALS: void isIdleChanged(); private: IndicatorServicePrivate *d_ptr; Q_DECLARE_PRIVATE(IndicatorService) }; } // namespace Q_DECLARE_METATYPE(QSet) #endif // SIGNON_UI_INDICATOR_SERVICE_H ./src/signon-ui.desktop.in0000644000015600001650000000033512701152050015566 0ustar jenkinsjenkins[Desktop Entry] Encoding=UTF-8 Version=1.0 Name=Account authentication Comment=Login to online accounts Exec=$${target.path}/$$TARGET Icon= Type=Application Terminal=false NoDisplay=true X-Ubuntu-Gettext-Domain=signon-ui ./src/http-warning.h0000644000015600001650000000204012701152050014444 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_HTTP_WARNING_H #define SIGNON_UI_HTTP_WARNING_H #include #include namespace SignOnUi { class HttpWarning: public QWidget { Q_OBJECT public: HttpWarning(QWidget *parent = 0); ~HttpWarning(); }; } // namespace #endif // SIGNON_UI_HTTP_WARNING_H ./src/qquick-dialog.h0000644000015600001650000000266212701152050014566 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2014 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_QQUICK_DIALOG_H #define SIGNON_UI_QQUICK_DIALOG_H #include #include namespace SignOnUi { namespace QQuick { class Dialog: public QQuickView { Q_OBJECT public: enum DialogCode { Rejected = 0, Accepted, }; enum ShowMode { TopLevel = 0, Transient, Embedded, }; explicit Dialog(QWindow *parent = 0); ~Dialog(); void show(WId parent, ShowMode mode); public Q_SLOTS: void accept(); void reject(); void done(int result); Q_SIGNALS: void finished(int result); protected: bool event(QEvent *e); }; } // namespace } // namespace #endif // SIGNON_UI_QQUICK_DIALOG_H ./src/com.canonical.indicators.webcredentials.xml0000644000015600001650000000554712701152050022246 0ustar jenkinsjenkins ./src/i18n.cpp0000644000015600001650000000210212701152050013133 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define NO_TR_OVERRIDE #include "i18n.h" #include namespace SignOnUi { void initTr(const char *domain, const char *localeDir) { bindtextdomain(domain, localeDir); textdomain(domain); } QString _(const char *text, const char *domain) { return QString::fromUtf8(dgettext(domain, text)); } }; // namespace ./src/service.cpp0000644000015600001650000001420312701152050014021 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "service.h" #include "cookie-jar-manager.h" #include "debug.h" #include "request.h" #include #include using namespace SignOnUi; namespace SignOnUi { typedef QQueue RequestQueue; static QVariant dbusValueToVariant(const QDBusArgument &argument) { QVariant ret; /* Note: this function should operate recursively, but it doesn't. */ if (argument.currentType() == QDBusArgument::MapType) { /* Assume that all maps are a{sv} */ ret = qdbus_cast(argument); } else { /* We don't know how to handle other types */ ret = argument.asVariant(); } return ret; } static QVariantMap expandDBusArguments(const QVariantMap &dbusMap) { QVariantMap map; QMapIterator it(dbusMap); while (it.hasNext()) { it.next(); if (qstrcmp(it.value().typeName(), "QDBusArgument") == 0) { QDBusArgument dbusValue = it.value().value(); map.insert(it.key(), dbusValueToVariant(dbusValue)); } else { map.insert(it.key(), it.value()); } } return map; } class ServicePrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(Service) public: ServicePrivate(Service *service); ~ServicePrivate(); RequestQueue &queueForWindowId(WId windowId); void enqueue(Request *request); void runQueue(RequestQueue &queue); void cancelUiRequest(const QString &requestId); void removeIdentityData(quint32 id); private Q_SLOTS: void onRequestCompleted(); private: mutable Service *q_ptr; /* each window Id has a different queue */ QMap m_requests; }; } // namespace ServicePrivate::ServicePrivate(Service *service): QObject(service), q_ptr(service) { } ServicePrivate::~ServicePrivate() { } RequestQueue &ServicePrivate::queueForWindowId(WId windowId) { if (!m_requests.contains(windowId)) { RequestQueue queue; m_requests.insert(windowId, queue); } return m_requests[windowId]; } void ServicePrivate::enqueue(Request *request) { Q_Q(Service); bool wasIdle = q->isIdle(); WId windowId = request->windowId(); RequestQueue &queue = queueForWindowId(windowId); queue.enqueue(request); if (wasIdle) { Q_EMIT q->isIdleChanged(); } runQueue(queue); } void ServicePrivate::runQueue(RequestQueue &queue) { Request *request = queue.head(); TRACE() << "Head:" << request; if (request->isInProgress()) { TRACE() << "Already in progress"; return; // Nothing to do } QObject::connect(request, SIGNAL(completed()), this, SLOT(onRequestCompleted())); request->start(); } void ServicePrivate::onRequestCompleted() { Q_Q(Service); Request *request = qobject_cast(sender()); WId windowId = request->windowId(); RequestQueue &queue = queueForWindowId(windowId); if (request != queue.head()) { BLAME() << "Completed request is not first in queue!"; return; } queue.dequeue(); request->deleteLater(); if (queue.isEmpty()) { m_requests.remove(windowId); } else { /* start the next request */ runQueue(queue); } if (q->isIdle()) { Q_EMIT q->isIdleChanged(); } } void ServicePrivate::cancelUiRequest(const QString &requestId) { Request *request = 0; /* Find the request; we don't know in which queue it is, so we must search * all queues. */ foreach (RequestQueue queue, m_requests) { foreach (Request *r, queue) { if (r->id() == requestId) { request = r; break; } } } TRACE() << "Cancelling request" << request; if (request != 0) { request->cancel(); } } void ServicePrivate::removeIdentityData(quint32 id) { /* Remove any data associated with the given identity. */ /* The BrowserRequest class uses CookieJarManager to store the cookies */ CookieJarManager::instance()->removeForIdentity(id); } Service::Service(QObject *parent): QObject(parent), d_ptr(new ServicePrivate(this)) { } Service::~Service() { } bool Service::isIdle() const { Q_D(const Service); return d->m_requests.isEmpty(); } QVariantMap Service::queryDialog(const QVariantMap ¶meters) { Q_D(Service); QVariantMap cleanParameters = expandDBusArguments(parameters); TRACE() << "Got request:" << cleanParameters; Request *request = Request::newRequest(connection(), message(), cleanParameters, this); d->enqueue(request); /* The following line tells QtDBus not to generate a reply now */ setDelayedReply(true); return QVariantMap(); } QVariantMap Service::refreshDialog(const QVariantMap &newParameters) { QVariantMap cleanParameters = expandDBusArguments(newParameters); QString requestId = Request::id(cleanParameters); // TODO find the request and update it /* The following line tells QtDBus not to generate a reply now */ setDelayedReply(true); return QVariantMap(); } void Service::cancelUiRequest(const QString &requestId) { Q_D(Service); d->cancelUiRequest(requestId); } void Service::removeIdentityData(quint32 id) { Q_D(Service); d->removeIdentityData(id); } #include "service.moc" ./src/browser-request.h0000644000015600001650000000263212701152050015202 0ustar jenkinsjenkins/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_BROWSER_REQUEST_H #define SIGNON_UI_BROWSER_REQUEST_H #include "request.h" #include namespace SignOnUi { class BrowserRequestPrivate; class BrowserRequest: public Request { Q_OBJECT public: explicit BrowserRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~BrowserRequest(); // reimplemented virtual methods void start(); private: BrowserRequestPrivate *d_ptr; Q_DECLARE_PRIVATE(BrowserRequest) }; } // namespace #endif // SIGNON_UI_BROWSER_REQUEST_H ./common-installs-config.pri0000644000015600001650000000277112701152050016173 0ustar jenkinsjenkins#----------------------------------------------------------------------------- # Common installation configuration for all projects. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # default installation target for applications #----------------------------------------------------------------------------- contains( TEMPLATE, app ) { target.path = $${INSTALL_PREFIX}/bin INSTALLS += target message("====") message("==== INSTALLS += target") } #----------------------------------------------------------------------------- # default installation target for libraries #----------------------------------------------------------------------------- contains( TEMPLATE, lib ) { target.path = $${INSTALL_PREFIX}/lib INSTALLS += target message("====") message("==== INSTALLS += target") # reset the .pc file's `prefix' variable #include( tools/fix-pc-prefix.pri ) } #----------------------------------------------------------------------------- # target for header files #----------------------------------------------------------------------------- !isEmpty( headers.files ) { headers.path = $${INSTALL_PREFIX}/include/$${TARGET} INSTALLS += headers message("====") message("==== INSTALLS += headers") } else { message("====") message("==== NOTE: Remember to add your API headers into `headers.files' for installation!") } # End of File ./README0000644000015600001650000000000112701152050011735 0ustar jenkinsjenkins ./po/0000755000015600001650000000000012701152050011504 5ustar jenkinsjenkins./po/update_pot.sh0000755000015600001650000000006212701152050014205 0ustar jenkinsjenkins#! /bin/bash cd ../src make ../po/signon-ui.pot ./po/Makefile0000644000015600001650000000104112701152050013140 0ustar jenkinsjenkins# Add here the language codes for the translated .po files: LINGUAS = I18N_DOMAIN = signon-ui PO_FILES = $(addsuffix .po, $(LINGUAS)) MO_FILES = $(addsuffix .mo, $(LINGUAS)) DEL_FILE = rm -f INSTALL = /usr/bin/install -c -m 644 MKDIR = mkdir -p all: $(MO_FILES) install: all for lang in $(LINGUAS); do \ dir=$(INSTALL_ROOT)/usr/share/locale/$$lang/LC_MESSAGES; \ $(MKDIR) $$dir; \ $(INSTALL) $$lang.mo $$dir/$(I18N_DOMAIN).mo; \ done %.mo: %.po msgfmt -o "$@" "$<" clean: -$(DEL_FILE) $(MO_FILES) distclean: clean check: all ./po/signon-ui.pot0000644000015600001650000000344712701152050014150 0ustar jenkinsjenkins# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-03-28 10:13+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: browser-request.cpp:268 msgid "" "The authentication process is complete.\n" "You may now close this dialog and return to the application." msgstr "" #: browser-request.cpp:274 msgid "Done" msgstr "" #: browser-request.cpp:291 msgid "Web authentication for %1" msgstr "" #: browser-request.cpp:294 msgid "Web authentication" msgstr "" #: dialog-request.cpp:105 msgid "Enter your credentials to login" msgstr "" #: dialog-request.cpp:107 msgid "Previous authentication attempt failed. Please try again." msgstr "" #: dialog-request.cpp:142 msgid "Enter your credentials" msgstr "" #: dialog-request.cpp:166 msgid "Username:" msgstr "" #: dialog-request.cpp:176 msgid "Password:" msgstr "" #: dialog-request.cpp:182 msgid "" "As an additional security measure, please fill in the text from the picture " "below:" msgstr "" #: dialog-request.cpp:191 msgid "Text from the picture:" msgstr "" #: indicator-service.cpp:140 msgid "Applications can no longer access some of your Web Accounts" msgstr "" #: indicator-service.cpp:143 msgid "Applications can no longer access your %1 Web Account" msgstr "" #: indicator-service.cpp:147 msgid "" "Choose Web Accounts from the user menu to reinstate access to this " "account." msgstr "" ./NOTES0000644000015600001650000000000112701152050011670 0ustar jenkinsjenkins ./common-project-config.pri0000644000015600001650000000232712701152050016005 0ustar jenkinsjenkins#----------------------------------------------------------------------------- # Common configuration for all projects. #----------------------------------------------------------------------------- CONFIG += link_pkgconfig # we don't like warnings... QMAKE_CXXFLAGS -= -Werror -Wno-write-strings # Disable RTTI QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti TOP_SRC_DIR = $$PWD TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) include( coverage.pri ) #----------------------------------------------------------------------------- # setup the installation prefix #----------------------------------------------------------------------------- INSTALL_PREFIX = /usr # default installation prefix # default prefix can be overriden by defining PREFIX when running qmake isEmpty(PREFIX) { message("====") message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'") message("==== (current installation path is `$${INSTALL_PREFIX}')") } else { INSTALL_PREFIX = $${PREFIX} message("====") message("==== install prefix set to `$${INSTALL_PREFIX}'") } isEmpty(LIBDIR) { LIBDIR = "$${INSTALL_PREFIX}/lib" } isEmpty(LIBEXECDIR) { LIBEXECDIR = "$${INSTALL_PREFIX}/libexec" } ./COPYING0000644000015600001650000010451312701152050012125 0ustar jenkinsjenkins 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 . ./signon-ui.pro0000644000015600001650000000045712701152050013526 0ustar jenkinsjenkinsinclude(common-vars.pri) include(common-project-config.pri) TEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ po \ src \ tests include(common-installs-config.pri) DISTNAME = $${PROJECT_NAME}-$${PROJECT_VERSION} dist.commands = "bzr export $${DISTNAME}.tar.bz2" QMAKE_EXTRA_TARGETS += dist ./TODO0000644000015600001650000000000112701152050011545 0ustar jenkinsjenkins ./INSTALL0000644000015600001650000000003612701152050012116 0ustar jenkinsjenkinsqmake make sudo make install ./coverage.pri0000644000015600001650000000355512701152050013405 0ustar jenkinsjenkins# Coverage CONFIG(coverage) { OBJECTS_DIR = MOC_DIR = TOP_SRC_DIR = $$PWD LIBS += -lgcov QMAKE_CXXFLAGS += --coverage QMAKE_LDFLAGS += --coverage QMAKE_EXTRA_TARGETS += coverage cov QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \ generate-coverage-html clean-coverage-html coverage-gcovr \ generate-gcovr generate-coverage-gcovr clean-coverage-gcovr clean-gcno.commands = \ "@echo Removing old coverage instrumentation"; \ "find -name '*.gcno' -print | xargs -r rm" clean-gcda.commands = \ "@echo Removing old coverage results"; \ "find -name '*.gcda' -print | xargs -r rm" coverage-html.depends = clean-gcda check generate-coverage-html generate-coverage-html.commands = \ "@echo Collecting coverage data"; \ "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \ "lcov --extract coverage.info \"*/src/*.cpp\" -o coverage.info"; \ "lcov --remove coverage.info \"moc_*.cpp\" -o coverage.info"; \ "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info" clean-coverage-html.depends = clean-gcda clean-coverage-html.commands = \ "lcov --directory $${TOP_SRC_DIR} -z"; \ "rm -rf coverage.info coverage-html" coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr generate-coverage-gcovr.commands = \ "@echo Generating coverage GCOVR report"; \ "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\"" clean-coverage-gcovr.depends = clean-gcda clean-coverage-gcovr.commands = \ "rm -rf $${TOP_SRC_DIR}/coverage.xml" QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml }