unity-webapps-qml-0.1+14.04.20140408/0000755000015301777760000000000012320723226017347 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tools/0000755000015301777760000000000012320723226020507 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tools/js-idl/0000755000015301777760000000000012320723226021671 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tools/js-idl/unity-webapps.idl0000644000015301777760000000464312320722666025210 0ustar pbusernogroup00000000000000dictionary UnityIndicatorProperties { Integer count; Date time; String iconURI; Callback onIndicatorActivated; }; interface UnityMessagingIndicatorInterface { method showIndicator (String name, optional UnityIndicatorProperties indicatorProperties); method clearIndicator (String name); method clearIndicators (); method addAction (String name, Callback onActionInvoked); method removeAction (String name); method removeActions (String name); method onPresenceChanged (Callback onPresenceChanged); readonly attribute String presence; }; interface UnityLauncherInterface { method setCount (Integer count); method clearCount (); method setProgress (Number progress); method clearProgress (); method setUrgent (Boolean urgnet); method addAction (String name, Callback onActionInvoked); method removeAction (String name); method removeActions (); }; interface UnityNotificationInterface { method showNotification (String summary, String body, optional String iconUrl); }; enum UnityPlaybackState { "Playing", "Paused" }; dictionary UnityTrackMetadata { String title; String? album; String? artist; String? artLocation; }; interface UnityMediaPlayerInterface { method setTrack (UnityTrackMetadata trackMetadata); method onPrevious (Callback onPreviousCallback); method onNext (Callback onNextCallback); method onPlayPause (Callback onPlayPauseCallback); method onPrevious (Callback onPreviousCallback); method onNext (Callback onNextCallback); method onPlayPause (Callback onPlayPauseCallback); method getPlaybackstate (Callback response); method setPlaybackstate (UnityPlaybackState state); method setCanGoNext (boolean cangonext); method setCanGoPrev (boolean cangoprev); method setCanPlay (boolean canplay); method setCanPause (boolean canpause); }; dictionary UnityInitParameters { String name; String iconUrl; Callback onInit; String? homepage; String? domain; }; interface Unity { method init (UnityInitParameters initializationParameters); method addAction (String actionName, Callback onActionInvoked); method removeAction (String actionName); method removeActions (); attribute UnityNotificationInterface Notification; attribute UnityMessagingIndicatorInterface MessagingIndicator; attribute UnityMediaPlayerInterface MediaPlayer; attribute UnityLauncherInterface Launcher; }; unity-webapps-qml-0.1+14.04.20140408/tools/js-idl/gen-api-from-idl.js0000755000015301777760000000345612320722666025300 0ustar pbusernogroup00000000000000#!/usr/bin/nodejs var WebIDL2 = require("webidl2"); var fs = require('fs'); if (process.argv.length < 3) { console.log('Invalid number of args'); process.exit(1); } var IDL_FILE = process.argv[2]; var _defs = {}; var processInterfaceDefinition = function(interfaceAst) { var name = interfaceAst.name; console.log('Interface "' + name + '"'); _defs.interfaces = _defs.interfaces || []; var iface = {name: name, members: { attributes: [], methods: [] }}; for (var i = 0; i < interfaceAst.members.length; ++i) { var member = interfaceAst.members[i]; console.log("\t" + member.name); console.log("\t\t" + member.type); if (member.type === 'operation') { var method = {name: member.name, args: []}; for (var j = 0; j < member.arguments.length; ++j) { console.log("\t\t\t" + member.arguments[j].name + ':' + member.arguments[j].idlType.idlType); method.args.push({name: member.arguments[j].name}); } iface.members.methods.push(method); } else { iface.members.attributes.push({name: member.name, type: member.idlType.idlType}); } }; _defs.interfaces.push(iface); } var generateUnityBindings = function(defs) { var unityif = defs.interfaces.filter(function (ifc) { return ifc.name === 'Unity'; }); if (!unityif.length) { console.log('Could not generate bindings'); return; } }; var processIdlFile = function (data) { var ast = WebIDL2.parse(data); for (var i = 0; i < ast.length; ++i) { console.log(ast[i].type); if (ast[i].type === "interface") { processInterfaceDefinition(ast[i]); } } generateUnityBindings(_defs); }; fs.readFile(IDL_FILE, 'utf8', function (err, data) { if (err) { console.log('Error while opening IDL file: ' + err); process.exit(1); } processIdlFile(data); }); unity-webapps-qml-0.1+14.04.20140408/tools/js-idl/README0000644000015301777760000000007312320722666022560 0ustar pbusernogroup00000000000000- requires nodejs - install WebIDL2: npm install webidl2 unity-webapps-qml-0.1+14.04.20140408/tools/tools.pro0000644000015301777760000000012512320722666022376 0ustar pbusernogroup00000000000000TEMPLATE=subdirs SUBDIRS = qml-launcher OTHER_FILES = \ $$system(ls ./js-idl/*) unity-webapps-qml-0.1+14.04.20140408/tools/inject-js-utils.py0000755000015301777760000000133612320722666024122 0ustar pbusernogroup00000000000000#!/usr/bin/env python import os import sys import re if len(sys.argv) < 3: print "Usage: FILE_TO_INSPECT OUT_FILENAME" sys.exit(1) FILE_TO_INSPECT=sys.argv[1] OUT_FILE=sys.argv[2] #read and parse content = open(FILE_TO_INSPECT).read() include_re = re.compile('\s*//@include\s+(.*)') includes = re.findall(include_re, content) injected_includes = {} for include in includes: try: injected_includes[include] = open(include).read().replace('.pragma library', '') except: print "Could not find file: ", include sys.exit(1) for include in includes: content = content.replace('//@include ' + include, injected_includes[include]) open(OUT_FILE, "w+").write(content) print OUT_FILE unity-webapps-qml-0.1+14.04.20140408/tools/qml-launcher/0000755000015301777760000000000012320723226023077 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tools/qml-launcher/qml-launcher.pro0000644000015301777760000000065212320722666026223 0ustar pbusernogroup00000000000000include(../../common-project-config.pri) include(../../common-vars.pri) TEMPLATE = app TARGET = unity-webapps-qml-launcher CONFIG += \ debug QT += \ core \ qml \ testlib \ quick SOURCES += \ qml-launcher.cpp include(../../common-installs-config.pri) desktop_files_installs.files = $$system(ls ./*.desktop) desktop_files_installs.path = /usr/share/applications INSTALLS += desktop_files_installs unity-webapps-qml-0.1+14.04.20140408/tools/qml-launcher/unitywebappsqmllauncher.desktop0000644000015301777760000000026312320722666031470 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Terminal=false Exec=/usr/bin/unity-webapps-qml-launcher $@ Name=Unity Webapps QML Test Launcher Icon=qmlscene NoDisplay=true X-Ubuntu-Touch=true unity-webapps-qml-0.1+14.04.20140408/tools/qml-launcher/qml-launcher.cpp0000644000015301777760000001327612320722666026213 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include #include #include #include #include #include namespace { void loadQtTestability(const QStringList & arguments) { // The testability driver is only loaded by QApplication but not by QGuiApplication. // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own. if (arguments.contains(QLatin1String("-testability"))) { QLibrary testLib(QLatin1String("qttestability")); if (testLib.load()) { typedef void (*TasInitialize)(void); TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); if (initFunction) { initFunction(); } else { qCritical("Library qttestability resolve failed!"); } } else { qCritical("Library qttestability load failed!"); } } } } // namespace int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); if (!app.arguments().count()) { qDebug() << "Invalid inputs args"; return EXIT_FAILURE; } loadQtTestability(app.arguments()); const QString QML_MAXIMIZED_ARG = "--maximized"; const QString QML_FILE_ARG_HEADER = "--qml="; const QString QML_FILE_IMPORT_ARG_HEADER = "--import="; const QString QML_APP_ID_ARG_HEADER = "--app-id="; const QString QML_INSPECTOR_ARG_HEADER = "--inspector="; const QString ARG_HEADER = "--"; const QString VALUE_HEADER = "="; QHash properties; QString qmlfile; QString appid; QString importPath; QString inspector; bool maximized = false; Q_FOREACH(QString argument, app.arguments()) { if (argument.contains(QML_FILE_ARG_HEADER)) { qmlfile = argument.right(argument.count() - QML_FILE_ARG_HEADER.count()); } else if (argument.contains(QML_FILE_IMPORT_ARG_HEADER)) { importPath = argument.right(argument.count() - QML_FILE_IMPORT_ARG_HEADER.count()); } else if (argument.contains(QML_APP_ID_ARG_HEADER)) { appid = argument.right(argument.count() - QML_APP_ID_ARG_HEADER.count()); } else if (argument.contains(QML_INSPECTOR_ARG_HEADER)) { inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count()); } else if (argument.contains(QML_MAXIMIZED_ARG)) { maximized = true; } else if (argument.startsWith(ARG_HEADER) && argument.right(argument.count() - ARG_HEADER.count()).contains("=")) { QString property = argument.right(argument.count() - ARG_HEADER.count()); property = property.left(property.indexOf(VALUE_HEADER)); QString value = argument.right(argument.count() - argument.indexOf(VALUE_HEADER) - 1); qDebug() << "Adding property: " << property << ", " << "value: " << value; properties.insert(property, value); } else { qDebug() << "Ignoring argument: " << argument; } } if (qmlfile.isEmpty()) { qDebug() << "No (or empty) QML file specified"; return EXIT_FAILURE; } if (!qmlfile.endsWith(".qml")) { qDebug() << "Invalid QML file name"; return EXIT_FAILURE; } QFileInfo f(qmlfile); if (!f.exists() || !f.isFile()) { qDebug() << "QML file not found or not a file: " << qmlfile; return EXIT_FAILURE; } if ( ! importPath.isEmpty()) { qDebug() << "Setting import path to: " << importPath; qputenv("QML2_IMPORT_PATH", importPath.toLatin1()); } if ( ! appid.isEmpty()) { qputenv("APP_ID", appid.toLatin1()); } if ( ! inspector.isEmpty()) { qDebug() << "Inspector server being set to: " << inspector; qputenv("QTWEBKIT_INSPECTOR_SERVER", inspector.toLatin1()); } QQmlEngine engine; QQmlContext *context = new QQmlContext(engine.rootContext()); QQmlComponent component(&engine, qmlfile); QObject *object = component.create(context); if (!component.isReady()) { qWarning() << component.errorString(); return -1; } if ( ! object) { qCritical() << "Cannot create object from qml base file"; return -1; } QQuickWindow* window = qobject_cast(object); QHash::iterator it; for(it = properties.begin(); properties.end() != it; ++it) { object->setProperty(it.key().toStdString().c_str(), QUrl(it.value())); } if (window) { if (maximized) window->showMaximized(); else window->show(); } return app.exec(); } unity-webapps-qml-0.1+14.04.20140408/common-project-config.pri0000644000015301777760000000063612320722666024276 0ustar pbusernogroup00000000000000#----------------------------------------------------------------------------- # Common configuration for all projects. #----------------------------------------------------------------------------- # we don't like warnings... QMAKE_CXXFLAGS += -Werror -Wno-write-strings # Disable RTTI QMAKE_CXXFLAGS += -fno-rtti TOP_SRC_DIR = $$PWD TOP_BUILD_DIR = $${TOP_SRC_DIR}/$${BUILD_DIR} include(coverage.pri) unity-webapps-qml-0.1+14.04.20140408/examples/0000755000015301777760000000000012320723226021165 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-qml-facebookmessenger-example.desktop0000644000015301777760000000065712320722666033306 0ustar pbusernogroup00000000000000[Desktop Entry] Name=FacebookMessengerWebappsQMLExample Type=Application Exec=/usr/bin/unity-webapps-qml-launcher --qml=/usr/share/unity-webapps-qml/examples/unity-webapps-example-facebookmessenger/main.qml --app-id=unity-webapps-qml-facebookmessenger-example Path=/usr/share/unity-webapps-qml/examples/unity-webapps-example-facebookmessenger GenericName=FacebookMessenger WebBrowser Container Example Icon=qmlscene Terminal=false unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-qml-basic-example.desktop0000644000015301777760000000052312320722666030675 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Exec=qmlscene /usr/share/unity-webapps-qml/examples/basic-webview/main.qml Path=/usr/share/unity-webapps-qml/examples/basic-webview Name=Unity WebApp QML Comonent - Basic API Showcase App GenericName=Unity WebApp QML Comonent for Ubuntu Basic API Showcase App Icon=drive-multidisk-symbolicx Terminal=false unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-example-facebookmessenger/0000755000015301777760000000000012320723226031105 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-example-facebookmessenger/main.qml0000644000015301777760000000275012320722666032557 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Window 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.UnityWebApps 0.1 Window { width: 640 height: 640 WebView { id: webView anchors.fill: parent width: parent.width height: parent.height experimental.userScripts: [] experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); } UnityWebApps { id: webapps name: "FacebookMessenger" bindee: webView model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'} } } } unity-webapps-qml-0.1+14.04.20140408/examples/examples.pro0000644000015301777760000000433612320722666023542 0ustar pbusernogroup00000000000000TEMPLATE = subdirs SUBDIRS += api-bindings OTHER_FILES += \ $$system(ls */*.qml) EXAMPLE_DATA_FILES = $$system(find ./data -type f | xargs) for(file, EXAMPLE_DATA_FILES) { OTHER_FILES += $$file } DESKTOP_EXAMPLE_FILES = \ unity-webapps-qml-basic-example.desktop \ unity-webapps-qml-bbcnews-example.desktop \ unity-webapps-qml-facebookmessenger-example.desktop \ unity-webapps-qml-model-example.desktop OTHER_FILES += $$DESKTOP_EXAMPLE_FILES desktop_files.path = /usr/share/applications desktop_files.files = $$DESKTOP_EXAMPLE_FILES common_data_files.path = /usr/share/unity-webapps-qml/examples/data/userscripts/common common_data_files.files = $$system(ls data/userscripts/common/*) html_data_files.path = /usr/share/unity-webapps-qml/examples/data/html html_data_files.files = $$system(ls data/html/*) bbcnews_userscript_data_files.path = /usr/share/unity-webapps-qml/examples/data/userscripts/unity-webapps-bbcnews bbcnews_userscript_data_files.files = $$system(ls data/userscripts/unity-webapps-bbcnews/*) bbcnews_example_install.path = /usr/share/unity-webapps-qml/examples/unity-webapps-example-bbcnews bbcnews_example_install.files = $$system(ls unity-webapps-example-bbcnews/*) facebookmessenger_userscript_data_files.path = /usr/share/unity-webapps-qml/examples/data/userscripts/unity-webapps-facebookmessenger facebookmessenger_userscript_data_files.files = $$system(ls data/userscripts/unity-webapps-facebookmessenger/*) facebookmessenger_example_install.path = /usr/share/unity-webapps-qml/examples/unity-webapps-example-facebookmessenger facebookmessenger_example_install.files = $$system(ls unity-webapps-example-facebookmessenger/*) basic_webview_install.path = /usr/share/unity-webapps-qml/examples/basic-webview basic_webview_install.files = $$system(ls basic-webview/*) webapps_apps_model_install.path = /usr/share/unity-webapps-qml/examples/webapps-apps-model webapps_apps_model_install.files = $$system(ls webapps-app-model/*) INSTALLS += desktop_files \ webapps_apps_model_install \ basic_webview_install \ common_data_files \ bbcnews_example_install \ bbcnews_userscript_data_files \ facebookmessenger_example_install \ facebookmessenger_userscript_data_files \ html_data_files unity-webapps-qml-0.1+14.04.20140408/examples/data/0000755000015301777760000000000012320723226022076 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/0000755000015301777760000000000012320723226024464 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-bbcnews/0000755000015301777760000000000012320723226030714 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-bbcnews/BBCNews.user.js0000644000015301777760000000256512320722666033471 0ustar pbusernogroup00000000000000// ==UserScript== // @include http://www.bbc.co.uk/news/ // @include http://www.bbc.com/news/ // @require utils.js // ==/UserScript== // This placeholder gets munged with real data at build time. const WebappsGettextDict = JSON.parse(unescape( "[]" )); window.Unity = external.getUnityObject('1.0'); function isCorrectPage() { var i, ids = ['tickerHolder']; for (i = 0; i < ids.length; i++) { if (!document.getElementById(ids[i])) { return false; } } return true; } function messagingIndicatorSetup() { if (!isCorrectPage()) { return; } var recent = document.getElementById('tickerHolder'); recent.addEventListener('DOMSubtreeModified', wrapCallback(function () { var title = null, node = document.evaluate('div/div/p/a', recent, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; if (node) { title = node.textContent; } if (title && !localStorage.getItem(title)) { localStorage.setItem(title, true); Unity.Notification.showNotification("BBC", title, null); } }), false); } Unity.init({ name: "BBC News", domain: 'bbc.co.uk', homepage: 'http://www.bbc.co.uk/news/', iconUrl: "icon://unity-webapps-bbc", onInit: wrapCallback(messagingIndicatorSetup) }); unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-bbcnews/manifest.json0000644000015301777760000000064312320722666033427 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/"], "requires": ["utils.js"], "name": "BBCNews", "scripts": ["BBCNews.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": { }, "domain": "bbc.co.uk", "homepage": "http://www.bbc.co.uk/news/", "license": "GPL-3" } unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-facebookmessenger/0000755000015301777760000000000012320723226032753 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017100000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-facebookmessenger/FacebookMessenger.user.jsunity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-facebookmessenger/Faceb0000644000015301777760000002754012320722666033715 0ustar pbusernogroup00000000000000// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // ==UserScript== // @include http://*.facebook.com/* // @include https://*.facebook.com/* // @include https://*.facebook.com // @require utils.js // ==/UserScript== // This placeholder gets munged with real data at build time. var WebappsGettextDict = JSON.parse(unescape( "%7B%22am%22%3A%20%7B%22Messages%22%3A%20%22%5Cu1218%5Cu120d%5Cu12a5%5Cu12ad%5Cu1276%5Cu127d%22%2C%20%22Notifications%22%3A%20%22%5Cu121b%5Cu1235%5Cu1273%5Cu12c8%5Cu1242%5Cu12eb%5Cu12ce%5Cu127d%22%7D%2C%20%22ar%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0627%5Cu0644%5Cu0631%5Cu0633%5Cu0627%5Cu0626%5Cu0644%22%2C%20%22Notifications%22%3A%20%22%5Cu0627%5Cu0644%5Cu062a%5Cu0646%5Cu0628%5Cu064a%5Cu0647%5Cu0627%5Cu062a%22%7D%2C%20%22ast%22%3A%20%7B%22Messages%22%3A%20%22Mensaxes%22%2C%20%22Notifications%22%3A%20%22Notificaciones%22%7D%2C%20%22be%22%3A%20%7B%22Messages%22%3A%20%22%5Cu041f%5Cu0430%5Cu0432%5Cu0435%5Cu0434%5Cu0430%5Cu043c%5Cu043b%5Cu0435%5Cu043d%5Cu043d%5Cu0456%22%2C%20%22Notifications%22%3A%20%22%5Cu0410%5Cu043f%5Cu0430%5Cu0432%5Cu044f%5Cu0448%5Cu0447%5Cu044d%5Cu043d%5Cu043d%5Cu0456%22%7D%2C%20%22bem%22%3A%20%7B%22Messages%22%3A%20%22Amashiwi%22%2C%20%22Notifications%22%3A%20%22Ifishibisho%22%7D%2C%20%22bg%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0421%5Cu044a%5Cu043e%5Cu0431%5Cu0449%5Cu0435%5Cu043d%5Cu0438%5Cu044f%22%2C%20%22Notifications%22%3A%20%22%5Cu0418%5Cu0437%5Cu0432%5Cu0435%5Cu0441%5Cu0442%5Cu044f%5Cu0432%5Cu0430%5Cu043d%5Cu0438%5Cu044f%22%7D%2C%20%22bs%22%3A%20%7B%22Messages%22%3A%20%22Poruke%22%2C%20%22Notifications%22%3A%20%22Obavje%5Cu0161tenja%22%7D%2C%20%22ca%22%3A%20%7B%22Messages%22%3A%20%22Missatges%22%2C%20%22Notifications%22%3A%20%22Notificacions%22%7D%2C%20%22ca%40valencia%22%3A%20%7B%22Messages%22%3A%20%22Missatges%22%2C%20%22Notifications%22%3A%20%22Notificacions%22%7D%2C%20%22cs%22%3A%20%7B%22Messages%22%3A%20%22Zpr%5Cu00e1vy%22%2C%20%22Notifications%22%3A%20%22Ozn%5Cu00e1men%5Cu00ed%22%7D%2C%20%22cy%22%3A%20%7B%22Messages%22%3A%20%22Negeseuon%22%2C%20%22Notifications%22%3A%20%22Hysbysiadau%22%7D%2C%20%22da%22%3A%20%7B%22Messages%22%3A%20%22Beskeder%22%2C%20%22Notifications%22%3A%20%22P%5Cu00e5mindelser%22%7D%2C%20%22de%22%3A%20%7B%22Messages%22%3A%20%22Mitteilungen%22%2C%20%22Notifications%22%3A%20%22Benachrichtigungen%22%7D%2C%20%22el%22%3A%20%7B%22Messages%22%3A%20%22%5Cu039c%5Cu03b7%5Cu03bd%5Cu03cd%5Cu03bc%5Cu03b1%5Cu03c4%5Cu03b1%22%2C%20%22Notifications%22%3A%20%22%5Cu0395%5Cu03b9%5Cu03b4%5Cu03bf%5Cu03c0%5Cu03bf%5Cu03b9%5Cu03ae%5Cu03c3%5Cu03b5%5Cu03b9%5Cu03c2%22%7D%2C%20%22en_AU%22%3A%20%7B%7D%2C%20%22en_CA%22%3A%20%7B%7D%2C%20%22en_GB%22%3A%20%7B%7D%2C%20%22en_US%22%3A%20%7B%7D%2C%20%22eo%22%3A%20%7B%22Messages%22%3A%20%22Mesa%5Cu011doj%22%2C%20%22Notifications%22%3A%20%22Atentigoj%22%7D%2C%20%22es%22%3A%20%7B%22Messages%22%3A%20%22Mensajes%22%2C%20%22Notifications%22%3A%20%22Notificaciones%22%7D%2C%20%22et%22%3A%20%7B%22Messages%22%3A%20%22S%5Cu00f5numid%22%2C%20%22Notifications%22%3A%20%22Teavitused%22%7D%2C%20%22eu%22%3A%20%7B%22Messages%22%3A%20%22Mezuak%22%2C%20%22Notifications%22%3A%20%22Jakinarazpenak%22%7D%2C%20%22fa%22%3A%20%7B%22Messages%22%3A%20%22%5Cu067e%5Cu06cc%5Cu0627%5Cu0645%5Cu200c%5Cu0647%5Cu0627%22%2C%20%22Notifications%22%3A%20%22%5Cu0622%5Cu06af%5Cu0627%5Cu0647%5Cu200c%5Cu0633%5Cu0627%5Cu0632%5Cu06cc%5Cu200c%5Cu0647%5Cu0627%22%7D%2C%20%22fi%22%3A%20%7B%22Messages%22%3A%20%22Viestit%22%2C%20%22Notifications%22%3A%20%22Ilmoitukset%22%7D%2C%20%22fr%22%3A%20%7B%7D%2C%20%22gd%22%3A%20%7B%22Messages%22%3A%20%22Teachdaireachdan%22%2C%20%22Notifications%22%3A%20%22Fiosan%22%7D%2C%20%22gl%22%3A%20%7B%22Messages%22%3A%20%22Mensaxes%22%2C%20%22Notifications%22%3A%20%22Notificaci%5Cu00f3ns%22%7D%2C%20%22gu%22%3A%20%7B%7D%2C%20%22he%22%3A%20%7B%22Messages%22%3A%20%22%5Cu05d4%5Cu05d5%5Cu05d3%5Cu05e2%5Cu05d5%5Cu05ea%22%2C%20%22Notifications%22%3A%20%22%5Cu05d4%5Cu05ea%5Cu05e8%5Cu05e2%5Cu05d5%5Cu05ea%22%7D%2C%20%22hi%22%3A%20%7B%7D%2C%20%22hr%22%3A%20%7B%7D%2C%20%22hu%22%3A%20%7B%22Messages%22%3A%20%22%5Cu00dczenetek%22%2C%20%22Notifications%22%3A%20%22%5Cu00c9rtes%5Cu00edt%5Cu00e9sek%22%7D%2C%20%22id%22%3A%20%7B%22Messages%22%3A%20%22Pesan%22%2C%20%22Notifications%22%3A%20%22Pemberitahuan%22%7D%2C%20%22is%22%3A%20%7B%22Messages%22%3A%20%22Skilabo%5Cu00f0%22%2C%20%22Notifications%22%3A%20%22Tilkynningar%22%7D%2C%20%22it%22%3A%20%7B%22Messages%22%3A%20%22Messaggi%22%2C%20%22Notifications%22%3A%20%22Notifiche%22%7D%2C%20%22ja%22%3A%20%7B%22Messages%22%3A%20%22%5Cu30e1%5Cu30c3%5Cu30bb%5Cu30fc%5Cu30b8%22%2C%20%22Notifications%22%3A%20%22%5Cu901a%5Cu77e5%22%7D%2C%20%22jbo%22%3A%20%7B%22Messages%22%3A%20%22notci%22%7D%2C%20%22ko%22%3A%20%7B%22Messages%22%3A%20%22%5Cuba54%5Cuc2dc%5Cuc9c0%22%2C%20%22Notifications%22%3A%20%22%5Cuc54c%5Cub9bc%22%7D%2C%20%22lt%22%3A%20%7B%22Messages%22%3A%20%22%5Cu017dinut%5Cu0117s%22%2C%20%22Notifications%22%3A%20%22Prane%5Cu0161imai%22%7D%2C%20%22lv%22%3A%20%7B%22Messages%22%3A%20%22Zi%5Cu0146ojumi%22%2C%20%22Notifications%22%3A%20%22Pazi%5Cu0146ojumi%22%7D%2C%20%22mhr%22%3A%20%7B%22Messages%22%3A%20%22%5Cu041a%5Cu0430%5Cu043b%5Cu0430%5Cu0441%5Cu044b%5Cu043c%5Cu0430%5Cu0448-%5Cu0432%5Cu043b%5Cu0430%5Cu043a%22%2C%20%22Notifications%22%3A%20%22%5Cu0423%5Cu0432%5Cu0435%5Cu0440%5Cu0442%5Cu0430%5Cu0440%5Cu044b%5Cu043c%5Cu0430%5Cu0448-%5Cu0432%5Cu043b%5Cu0430%5Cu043a%22%7D%2C%20%22mk%22%3A%20%7B%7D%2C%20%22ml%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0d38%5Cu0d28%5Cu0d4d%5Cu0d26%5Cu0d47%5Cu0d36%5Cu0d19%5Cu0d4d%5Cu0d19%5Cu0d7e%22%2C%20%22Notifications%22%3A%20%22%5Cu0d05%5Cu0d31%5Cu0d3f%5Cu0d2f%5Cu0d3f%5Cu0d2a%5Cu0d4d%5Cu0d2a%5Cu0d41%5Cu0d15%5Cu0d7e%22%7D%2C%20%22mr%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0938%5Cu0902%5Cu0926%5Cu0947%5Cu0936%22%7D%2C%20%22ms%22%3A%20%7B%22Messages%22%3A%20%22Mesej%22%2C%20%22Notifications%22%3A%20%22Pemberitahuan%22%7D%2C%20%22my%22%3A%20%7B%22Messages%22%3A%20%22%5Cu1005%5Cu102c%5Cu1019%5Cu103b%5Cu102c%5Cu1038%22%2C%20%22Notifications%22%3A%20%22%5Cu1021%5Cu101e%5Cu102d%5Cu1015%5Cu1031%5Cu1038%5Cu1001%5Cu103b%5Cu1000%5Cu103a%22%7D%2C%20%22nb%22%3A%20%7B%7D%2C%20%22nl%22%3A%20%7B%22Messages%22%3A%20%22Berichten%22%2C%20%22Notifications%22%3A%20%22Notificaties%22%7D%2C%20%22oc%22%3A%20%7B%22Messages%22%3A%20%22Messatges%22%2C%20%22Notifications%22%3A%20%22Notificacions%22%7D%2C%20%22os%22%3A%20%7B%7D%2C%20%22pl%22%3A%20%7B%22Messages%22%3A%20%22Wiadomo%5Cu015bci%22%2C%20%22Notifications%22%3A%20%22Powiadomienia%22%7D%2C%20%22pt%22%3A%20%7B%22Messages%22%3A%20%22Mensagens%22%2C%20%22Notifications%22%3A%20%22Notifica%5Cu00e7%5Cu00f5es%22%7D%2C%20%22pt_BR%22%3A%20%7B%22Messages%22%3A%20%22Mensagens%22%2C%20%22Notifications%22%3A%20%22Notifica%5Cu00e7%5Cu00f5es%22%7D%2C%20%22ro%22%3A%20%7B%22Messages%22%3A%20%22Mesaje%22%2C%20%22Notifications%22%3A%20%22Notific%5Cu0103ri%22%7D%2C%20%22ru%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0421%5Cu043e%5Cu043e%5Cu0431%5Cu0449%5Cu0435%5Cu043d%5Cu0438%5Cu044f%22%2C%20%22Notifications%22%3A%20%22%5Cu0423%5Cu0432%5Cu0435%5Cu0434%5Cu043e%5Cu043c%5Cu043b%5Cu0435%5Cu043d%5Cu0438%5Cu044f%22%7D%2C%20%22se%22%3A%20%7B%22Messages%22%3A%20%22Reivvet%22%2C%20%22Notifications%22%3A%20%22Muittuhusat%22%7D%2C%20%22shn%22%3A%20%7B%22Messages%22%3A%20%22%5Cu101c%5Cu102d%5Cu1075%5Cu103a%5Cu1088%5Cu1075%5Cu1082%5Cu1062%5Cu1019%5Cu103a%5Cu1038%5Cu1015%5Cu103d%5Cu1010%5Cu103a%5Cu1038%22%2C%20%22Notifications%22%3A%20%22%5Cu1076%5Cu1031%5Cu1083%5Cu1088%5Cu107d%5Cu1062%5Cu1004%5Cu1037%5Cu103a%5Cu1015%5Cu107c%5Cu103a%22%7D%2C%20%22sk%22%3A%20%7B%22Messages%22%3A%20%22Spr%5Cu00e1vy%22%2C%20%22Notifications%22%3A%20%22Ozn%5Cu00e1menia%22%7D%2C%20%22sl%22%3A%20%7B%22Messages%22%3A%20%22Sporo%5Cu010dila%22%2C%20%22Notifications%22%3A%20%22Obvestila%22%7D%2C%20%22sq%22%3A%20%7B%22Messages%22%3A%20%22Mesazhet%22%2C%20%22Notifications%22%3A%20%22Njoftime%22%7D%2C%20%22sr%22%3A%20%7B%22Messages%22%3A%20%22%5Cu041f%5Cu043e%5Cu0440%5Cu0443%5Cu043a%5Cu0435%22%2C%20%22Notifications%22%3A%20%22%5Cu041e%5Cu0431%5Cu0430%5Cu0432%5Cu0435%5Cu0448%5Cu0442%5Cu0435%5Cu045a%5Cu0430%22%7D%2C%20%22sv%22%3A%20%7B%7D%2C%20%22tg%22%3A%20%7B%22Messages%22%3A%20%22%5Cu041f%5Cu0430%5Cu0451%5Cu043c%5Cu04b3%5Cu043e%22%2C%20%22Notifications%22%3A%20%22%5Cu041e%5Cu0433%5Cu043e%5Cu04b3%5Cu0438%5Cu04b3%5Cu043e%22%7D%2C%20%22th%22%3A%20%7B%7D%2C%20%22tr%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0130letiler%22%2C%20%22Notifications%22%3A%20%22Bildirimler%22%7D%2C%20%22ug%22%3A%20%7B%22Messages%22%3A%20%22%5Cu0626%5Cu06c7%5Cu0686%5Cu06c7%5Cu0631%5Cu0644%5Cu0627%5Cu0631%22%2C%20%22Notifications%22%3A%20%22%5Cu0626%5Cu06c7%5Cu0642%5Cu062a%5Cu06c7%5Cu0631%5Cu06c7%5Cu0634%5Cu0644%5Cu0627%5Cu0631%22%7D%2C%20%22uk%22%3A%20%7B%22Messages%22%3A%20%22%5Cu041f%5Cu043e%5Cu0432%5Cu0456%5Cu0434%5Cu043e%5Cu043c%5Cu043b%5Cu0435%5Cu043d%5Cu043d%5Cu044f%22%2C%20%22Notifications%22%3A%20%22%5Cu0421%5Cu043f%5Cu043e%5Cu0432%5Cu0456%5Cu0449%5Cu0435%5Cu043d%5Cu043d%5Cu044f%22%7D%2C%20%22uz%22%3A%20%7B%22Messages%22%3A%20%22Xabarlar%22%2C%20%22Notifications%22%3A%20%22Eslatmalar%22%7D%2C%20%22vi%22%3A%20%7B%22Messages%22%3A%20%22Tin%20nh%5Cu1eafn%22%2C%20%22Notifications%22%3A%20%22Th%5Cu00f4ng%20b%5Cu00e1o%22%7D%2C%20%22zh_CN%22%3A%20%7B%22Messages%22%3A%20%22%5Cu6d88%5Cu606f%22%2C%20%22Notifications%22%3A%20%22%5Cu901a%5Cu77e5%22%7D%2C%20%22zh_HK%22%3A%20%7B%22Messages%22%3A%20%22%5Cu8a0a%5Cu606f%22%2C%20%22Notifications%22%3A%20%22%5Cu901a%5Cu77e5%22%7D%2C%20%22zh_TW%22%3A%20%7B%22Messages%22%3A%20%22%5Cu8a0a%5Cu606f%22%2C%20%22Notifications%22%3A%20%22%5Cu901a%5Cu77e5%22%7D%2C%20%22zn_CN%22%3A%20%7B%7D%7D" )); window.Unity = external.getUnityObject('1.0'); function isCorrectPage() { var i, ids = ['mercurymessagesCountValue']; for (i = 0; i < ids.length; i++) { if (!document.getElementById(ids[i])) { return false; } } return true; } function getMessageCountElement() { return document.getElementById('mercurymessagesCountValue'); } function getNotificationCountElement() { return document.getElementById('notificationsCountValue'); } function selfTest() { if (!getMessageCountElement()) { reportTestState('FAILED: getMessageCountElement is null'); return; } if (!getNotificationCountElement()) { reportTestState('FAILED: getNotificationCountElement is null'); return; } reportTestState('PASS SELF TEST'); } function messagingIndicatorSetup() { if (!isCorrectPage()) { return; } var countElement = getMessageCountElement(); var notificationElement = getNotificationCountElement(); function checkMessagesCount() { var indicators = []; function makeCallback(node) { return function () { launchClickEvent(node.parentNode); }; } indicators.push({ name: _("Messages"), count: countElement.textContent, callback: makeCallback(countElement) }); indicators.push({ name: _("Notifications"), count: notificationElement.textContent, callback: makeCallback(notificationElement) }); return indicators; } var indicatorsController = new Indicators(checkMessagesCount); if (document.location.hostname === 'apps.facebook.com') { var name = document.evaluate('//div[@role="contentinfo"]/div/span', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.textContent; linkVisited(document.location.toString(), name); } console.log(JSON.stringify(checkMessagesCount())); selfTest(); } if (document.getElementById('email')) { var email = document.getElementById('email'); window.onunload = function () { localStorage.setItem('login', email.value); }; } var login = localStorage.getItem('login'); if (!login) { login = null; } Unity.init({ name: "facebook", iconUrl: "icon://unity-webapps-facebook", login: login, domain: 'facebook.com', homepage: 'https://www.facebook.com/', onInit: wrapCallback(messagingIndicatorSetup) }); ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-facebookmessenger/manifest.jsonunity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/unity-webapps-facebookmessenger/manif0000644000015301777760000000116112320722666033776 0ustar pbusernogroup00000000000000{"includes":["http://*.facebook.com/*","https://*.facebook.com/*","https://*.facebook.com"],"requires":["utils.js"],"name":"FacebookMessenger","scripts":["FacebookMessenger.user.js"],"maintainer":"Webapps Team ","license":"GPL-3","manifest-version":"1.0","integration-version":"2.4.12","package-name":"FacebookMessenger","description":"Unity Webapp for FacebookMessenger","icons":{"128":"128/unity-webapps-facebook.png","48":"48/unity-webapps-facebook.png","52":"52/unity-webapps-facebook.png","64":"64/unity-webapps-facebook.png"},"domain":"facebook.com","homepage":"https://www.facebook.com/"} unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/common/0000755000015301777760000000000012320723226025754 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/userscripts/common/utils.js0000644000015301777760000002247712320722666027475 0ustar pbusernogroup00000000000000// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- function _(strid) { var lang = unsafeWindow.navigator.language; lang = lang.toLowerCase().replace(/-/g, '_'); while (lang) { if (WebappsGettextDict.hasOwnProperty(lang) && WebappsGettextDict[lang].hasOwnProperty(strid)) { return WebappsGettextDict[lang][strid]; } lang = lang.substr(0, lang.lastIndexOf('_')); } console.log('Gettext _() failed to find translation.') return strid; } /** * WARNING: this is only kept here for backward compatibility reasons. * This needs to be as soon as the individual scripts are SRUed and * updated to use the latest mechanism */ var _previousIndicators = []; function showIndicators(list) { if (list.length == _previousIndicators.length) { var same = true; for (var i = 0; i < list.length; i++) { if (list[i].name != _previousIndicators[i].name) same = false; if (list[i].count != _previousIndicators[i].count) same = false; } if (same) return; } _previousIndicators = list; Unity.MessagingIndicator.clearIndicators(); for (var i = 0; i < list.length; i++) { Unity.MessagingIndicator.showIndicator(list[i].name, { count: list[i].count, callback: list[i].callback }); } } function trim(str) { return str.replace(/^\s+|\s+$/g, ""); } var KEY_NAME = '____unity_indicators_sync'; function Indicators(getCounters, combineFromMultipleTabs) { this._init(getCounters, combineFromMultipleTabs); } Indicators.prototype = { _prevIndicators: null, _getCountersCb: null, _init: function(getCounters, combineFromMultipleTabs) { this._last = {}; this._timestamp = new Date(); this._prevIndicators = []; this._getCountersCb = getCounters; this._combineFromMultipleTabs = combineFromMultipleTabs; window.addEventListener('blur', this._onBlur.bind(this)); window.addEventListener('focus', this._onFocus.bind(this)); setInterval(this._updateIndicators.bind(this), 8000); this._updateIndicators(true); }, _onBlur: function() { }, _onFocus: function() { this._timestamp = new Date(); this.visited(this._currentLabel); }, _updateTotal: function(total) { if (this._combineFromMultipleTabs) { return; } if (total) { Unity.Launcher.setCount(Number(total)); } else { Unity.Launcher.clearCount(); } }, _updateIndicators: function(firstRun) { var state = localStorage.getItem(KEY_NAME); var updateState = false; try { var list = this._getCountersCb(); } catch (e) { return; } if (state) { if (!this._combineFromMultipleTabs) { state = JSON.parse(state); if (state.timestamp > this._timestamp) { this._timestamp = state.timestamp; this._prevIndicators = state.prevIndicators; this._last = state.lastValue; } else { updateState = true; } } } else { updateState = true; } if (!firstRun && !this._forceUpdate && list.length == this._prevIndicators.length) { var same = true; for (var i = 0; i < list.length; i++) { if (list[i].name != this._prevIndicators[i].name) same = false; if (list[i].count != this._prevIndicators[i].count) same = false; } if (same) return; } this._forceUpdate = false; var total = 0; if (!this._combineFromMultipleTabs) { Unity.MessagingIndicator.clearIndicators(); } for (var i = 0; i < list.length; i++) { var count = 0; if (!this._last[list[i].name]) { this._last[list[i].name] = 0; } if (this._last[list[i].name]) { if (this._last[list[i].name] < Number(list[i].count)) { count = Number(list[i].count) - this._last[list[i].name]; } else { count = 0; } } else { this._last[list[i].name] = list[i].count; } if (!count) { if (this._combineFromMultipleTabs) { Unity.MessagingIndicator.clearIndicator(list[i].name); } continue; } total += count; if (!firstRun) { Unity.MessagingIndicator.showIndicator(list[i].name, { count: count, callback: list[i].callback }); } else { this._last[list[i].name] = Number(list[i].count); } } if (!firstRun) { this._updateTotal(total); } this._prevIndicators = list; try { if (updateState) { this._saveState(); } else { localStorage.setItem(KEY_NAME, JSON.stringify(state)); } } catch (e) { setTimeout((function () {this._updateIndicators(firstRun)}).bind(this), 500); } }, _saveState: function() { localStorage.setItem(KEY_NAME, JSON.stringify({ timestamp: new Date(), prevIndicators: this._prevIndicators, lastValue: this._last })); }, visited: function(labelName) { this._currentLabel = labelName; var count = 0; for (var i = 0; i < this._prevIndicators.length; i++) { if (this._prevIndicators[i].name == labelName) { count = this._prevIndicators[i].count; } } this._forceUpdate = true; this._last[labelName] = count; this._saveState(); this._updateIndicators(false); } }; /** * On Chrommium v18 (and maybe earlier versions) the click() function * does not seem to work on otherwise proper DOM elements (that are supposed * to support click() as per the spec), e.g. SPAN elements etc. */ function launchClickEvent(node) { var doclick = node.click ? node.click.bind(node) : function () { var e = unsafeWindow.document.createEvent('MouseEvents'); e.initMouseEvent("click", true, true, unsafeWindow, 1, 1, 1, 1, 1, false, false, false, false, 0, node); node.dispatchEvent(e); }; doclick(); } function click(node) { var event = unsafeWindow.document.createEvent("MouseEvents"); event.initMouseEvent("mousedown", true, true, unsafeWindow, 0, 0, 0, 0, 0, false, false, false, false, 0, null); node.dispatchEvent(event); event = unsafeWindow.document.createEvent("MouseEvents"); event.initMouseEvent("mouseup", true, true, unsafeWindow, 0, 0, 0, 0, 0, false, false, false, false, 0, null); node.dispatchEvent(event); } function evalInPageContext(func) { var script = document.createElement('script'); script.appendChild(document.createTextNode('(' + func + ')();')); (document.body || document.head || document.documentElement).appendChild(script); } function makeRedirector(link) { return function () { evalInPageContext('function() {window.location = "' + link + '";}'); }; } function wrapCallback(callback) { return function () { try { callback.apply(window, arguments); } catch (x) { console.log(x); } }; } var MAX_PINS = 10; var FAVORITES = '____unity_favorites'; function addFavoritesInLauncher(links) { var i; if (!links) { return; } Unity.Launcher.removeActions(); links.sort(function (a, b) { if (a.count > b.count) { return -1; } if (a.count < b.count) { return 1; } return 0; }); links.splice(MAX_PINS); for (i = 0; i < links.length; i++) { if (links[i].name) { Unity.Launcher.addAction(links[i].name, makeRedirector(links[i].url)); } } } if (!window.reportTestState) { window.reportTestState = function (msg) { console.log(msg); }; } function linkVisited(url, name, second) { var i, links = localStorage.getItem(FAVORITES); if (!links) { links = []; if (!second) { setTimeout(wrapCallback(function () { linkVisited(url, name, true); }), 1000); return; } } else { links = JSON.parse(links); } if (!name) { addFavoritesInLauncher(links); return; } var obj = null; for (i = 0; i < links.length; i++) { if (links[i].url === url) { obj = links[i]; } } if (!obj) { obj = { url: url, name: name, count: 0 }; links.push(obj); } obj.count++; localStorage.setItem(FAVORITES, JSON.stringify(links)); addFavoritesInLauncher(links); } unity-webapps-qml-0.1+14.04.20140408/examples/data/html/0000755000015301777760000000000012320723226023042 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/data/html/big-test.html0000644000015301777760000001750712320722666025467 0ustar pbusernogroup00000000000000 Unity Web API Tests
Back

Unity Web Launcher Actions (Quicklist) Tests

Add Actions (and Listen for Callbacks)

Active Test Quicklist Entries from the Launcher (1 and 2)

Back

Unity Launcher Web API Tests

To use the Launcher tests you will first have to add the desktop file for the test application to the launcher! The easiest way to do this is to drag it from your user applications directly, likely ~/.local/share/applications

Clear Launcher Properties

Back

Unity Web Music Player Callback Tests

Listen for Callbacks

Activate Test Music Player Callbacks from the Sound Menu

Back

Unity Web Indicator Callback Tests

Add Indicators (with Callbacks)

Activate Indicator with Callback 1 and 2 from the Messaging Indicator

Indicator Callback 1: Waiting

Indicator Callback 2: Waiting

Back

Unity Web Indicator Action Callback Tests

Add Actions (with Callbacks)

Activate Actions with Callback 1 and 2 from the Messaging Indicator

Action Callback 1: Waiting

Action Callback 2: Waiting

Back

Unity Web Notification API Tests

unity-webapps-qml-0.1+14.04.20140408/examples/data/html/big-test.js0000644000015301777760000002132512320722666025130 0ustar pbusernogroup00000000000000var Unity = external.getUnityObject('1.0'); var data_uri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKBw0vIqzujI4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAGhklEQVRo3t2bT0gbeRTHv/MnMRl3XAoNC81hipeOs0cTTyUFpbsbwZquWHpJKHRprYUKXiK4Pe2G6qXQlka3bEFiD7KSVldoKksKHXpK4nHH9FIa2AjdLJQ1NZpkMtmDras1ycykxiS+o87vl/nMe/N+3/fm9yOKxSJqZG0ATiupZKeSWhMKq5F2ACcAHAPQCkABsAngHcXxa2DaXtOCXQKwAuAlgPVa3BRxwMCckkoOyrFwn7zy3FF4E0cxk9Y1AcXxoIQu0B02kbb1LAGYB5BoKOBiJt2bf/HkSl5c7C8k4gfnDYYFbeuB0elepDj+AYCndQUuZtK9uVDAmwvNOvR6Uq/Rgh3G76+LtGCf/BzwaoG5XCgwkQ36L9YatBS46apvjrRYx6oJdd3AhUT88tb0+J1CIt6KOhnBsDA63RstA9dHADysGXBeXPBvTo9fQ4MYLdhhHr03RTDs8EEDt21Oj/+WFxe+RYMZabHCPHp3meL4C1qWMlXgYib91VZg4ve8uNCFBjWCYcHcnIlQHH8OwNvPAW7L/HzpD1mKNixsCeizlTxdEXhzevyZnjA2OFww2LpBCV0gGBYAoKSSkGNh5J49gpJKVhxH23p2J0cUpEjFcWWglymO/043cDZ4358N+jUlKIrjYRrygeL4itdlg/eRDfp1jStm0sgG/ciFAprf6dZbwbKJrCSwHAtfzty+8atWWObmzI5HNWR6bE6PVz1Oa/Zmfpz5odSStQ+4mElz72+c/bOYSbdqCaHWW0GQFquu9y0XCsBw5rxm2I+2NTup2dMmt3fD6PR8/ak4IUu8txNaYAHA6HTrht0e59ENCwAtA8Oax2WD/lYllZzYF/J7QlmK9sqx8EU9N37Ymdhw5rxWnY+t2cmLAHrLAuce3/fqUTnVeOmz1VVnt+Zr5VgYshT1lgSWpWivLEUdmhUO11EnZXVCX754fN+x28vkrn9c0RdeX9RNSuoxWYpCSSWv7AFWUklOlqL9uqqm1WhdgGVJ/+9mg/5+ANwOsBwLD+qdpPAmXhdgJbGq/yHFwgAwuAOcFxf7quh2fJzoUC337BGqvNc+ACAKf//V9n7km3/1ZGeDwwWqw17VGnxQYS2vPEf+xRPNTUKj0wOT2/slXViNnta6BppH74EW7A1R+NOCHS0Dw9gKTCAvLqi/glIEAE7ThcSrTo2CvC7rrqoThnw7WlulNQUAnaSSWBXUJjaP3m042D33N+TbU1pWgBZIJbXWrqZf1cq+RoFWc0pxI91OKqnkCbWivhnsY9O+snaInCCx/a2nbK1br0xcjRlsqjr7GAnAXPapNREsAIBpU4188iB1azMYie1Plgcm4xrcNkkA7xpNL9dQZ78jAaxV0qBaVEyjmJrOJi3WNZIW7K9VSqvmgA0FVPvXxHHra5I4bpUqhkkqqbk9Wi8rJOKaHEOd5CWS4k6tqF2opydcD9jMT5dUqyaCYUEw7ApNCV0vtUycFxdQWI3C5PZq0q01T1CpJLJBv+YcQwldAPCSpjh+nWBYsZhJO7T8SOb2DRAMC+okD6rDXgfQNSiJOPTuJTHYukUA6zQA0Laepby4oLljWcykt4twKYpmMarDvrTT4jHYuudxhI0W7CAt1vkdYNrWkyAt1sWjCmxwuBbx4RsT+f8f+x8cRViCYWFwuB7s1tIAAKPT85RgWPGoARudbhG79nWRu5+E0emePGreNTo9k59WS9jtZdJinTsqwCbP2BzBsE/LAhMMC5PbOwZg4whk5g2DwzVWqh7ee6GtJ2FwuEaaPZRNV30jKLE1kSwTCg8pjp9qVmDzkG+KtFgflut4lH5CQ75hgmGXmy8re5ZpW89wpRZPaSm2vcvmAsGwkSYSGBGT23uhYhOgov7k+HXm5sy5ZoA2OFwR85DvHFT2W5Kqopvj3zI3Z842cngbHK5l85DvLFT2WQI6tg8XEnFsTY/7C4n4tUaCNbm9U0an58C3D++Uhdmg/3IuFLiD7ZMpdTPSYt0wj94doTi+dhvEP5osRbmtX8YnlFTyYj1gjU7PXMvA8BjBsLU/ArDb27lQoDcXmvVq6ZYckHoSW9xjkxTHH/ohj33geXHxipJK9tcoKS0aHK4HtGCv7zGefaEeC3P52PNBORbu+1yv04JdpDu7lwxnzs9XE7qHAvxJVm8rSJHThcSrzuI/SUFJrbV/+Ba97ygeLdjXwLS9prhTEsXxK5TQ9ZJg2JocxfsPlPjVREHRwK4AAAAASUVORK5CYII="; var icon_uri = "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-server.png"; function addLauncherTests() { $("#launcherTest1Button").click(function (){ Unity.Launcher.setCount(7); }); $("#launcherTest2Button").click(function (){ Unity.Launcher.setProgress(0.3); }); $("#launcherTest3Button").click(function (){ Unity.Launcher.setUrgent(); }); $("#launcherClearButton").click(function (){ Unity.Launcher.clearCount(); Unity.Launcher.clearProgress(); }); $("#launcherRemoveActionsBulk").click(function(){ Unity.Launcher.removeActions(); }); $("#launcherRemoveAction").click(function(){ Unity.Launcher.removeAction("Test Action 1"); }); $("#launcherAddActionsButton").click(function(){ var makeLauncherCallback = function(label) { return function () { $("#launcherCallbackLog").html($("#launcherCallbackLog").html()+label+"
"); } }; Unity.Launcher.addAction("Test Action 1", makeLauncherCallback("Test Action 1")); Unity.Launcher.addAction("Test Action 2", makeLauncherCallback("Test Action 2")); }); } function addNotificationTests(){ $("#notificationTest1Button").click(function (){ Unity.Notification.showNotification("Test notification", "Showing a simple test notification", null); }); $("#notificationTest2Button").click(function (){ Unity.Notification.showNotification("Test notification", "Showing a test notification with an image URL", "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png"); }); $("#notificationTest3Button").click(function (){ Unity.Notification.showNotification("Test notification", "Showing a test notification with a data URI", data_uri); }); } function addMediaPlayerTests(){ $("#musicPlayerInitButton").click(function(){ Unity.MediaPlayer.init("Wha"); }); $("#musicPlayerTest1Button").click(function(){ Unity.MediaPlayer.setTrack({artist: "Test artist", album: "Test album", title: "Test", artLocation: null}); }); $("#musicPlayerTest2Button").click(function(){ Unity.MediaPlayer.setTrack({artist: "Test artist", album: "Test album", title: "Test", artLocation: icon_uri}); }); $("#musicPlayerTest3Button").click(function(){ Unity.MediaPlayer.setTrack({artist: "Test artist", album: "Test album", title: "Test", artLocation: data_uri}); }); $("#musicPlayerPlaybackStateButton").click(function(){ Unity.MusicPlayer.getPlaybackState( function (playbackstate) { Unity.MediaPlayer.setPlaybackState( ! playbackstate); } ); }); $("#musicPlayerAddCallbacksButton").click(function(){ Unity.MediaPlayer.onNext(function() { $("#musicPlayerCallbackLog").html($("#musicPlayerCallbackLog").html()+"
Next"); }); Unity.MediaPlayer.onPrevious(function() { $("#musicPlayerCallbackLog").html($("#musicPlayerCallbackLog").html()+"
Previous"); }); Unity.MediaPlayer.onPlayPause(function() { $("#musicPlayerCallbackLog").html($("#musicPlayerCallbackLog").html()+"
Play/Pause"); }); }); } function addIndicatorTests() { $("#clearButton").click(function (){ Unity.MessagingIndicator.clearIndicator("Simple test indicator"); Unity.MessagingIndicator.clearIndicator("Indicator with Count"); Unity.MessagingIndicator.clearIndicator("Indicator with Time"); Unity.MessagingIndicator.clearIndicator("Indicator with Icon"); Unity.MessagingIndicator.clearIndicator("Indicator with Icon (Data URI)"); Unity.MessagingIndicator.clearIndicator("Indicator with Callback (1)"); Unity.MessagingIndicator.clearIndicator("Indicator with Callback (2)"); }); $("#indicatorTest1Button").click(function (){ Unity.MessagingIndicator.showIndicator("Simple test indicator"); }); $("#indicatorTest2Button").click(function(){ Unity.MessagingIndicator.showIndicator("Indicator with Count", {count: "103"}); }); $("#indicatorTest3Button").click(function(){ Unity.MessagingIndicator.showIndicator("Indicator with Time", {time: new Date()}); }); $("#indicatorTest4Button").click(function(){ Unity.MessagingIndicator.showIndicator("Indicator with Icon", {icon: icon_uri}); }); $("#indicatorTest5Button").click(function(){ Unity.MessagingIndicator.showIndicator("Indicator with Icon (Data URI)", {icon: data_uri}); }); $("#indicatorTest6Button").click(function(){ Unity.MessagingIndicator.addAction("Test action", function(){}); }); $("#indicatorCallbackAddButton").click(function(){ var callback1 = function() { $("#indicatorCallback1Label").text("Indicator Callback 1: Success"); } var callback2 = function() { $("#indicatorCallback2Label").text("Indicator Callback 2: Success"); } Unity.MessagingIndicator.showIndicator("Indicator with Callback (1)", callback1); Unity.MessagingIndicator.showIndicator("Indicator with Callback (2)", callback2); }); $("#indicatorActionCallbackAddButton").click(function(){ var callback1 = function() { $("#indicatorActionCallback1Label").text("Action Callback 1: Success"); } var callback2 = function() { $("#indicatorActionCallback2Label").text("Action Callback 2: Success"); } Unity.MessagingIndicator.addAction("Action with Callback (1)", callback1); Unity.MessagingIndicator.addAction("Action with Callback (2)", callback2); }); } function addHUDTest() { $("#HUDAddActions").click(function(){ function addAction(name) { Unity.addAction(name, function() { $("#indicatorActionCallback2Label").text(name); }); } addAction('/HUD/haveAniceDay'); addAction('/HUD/dontBeEvil'); addAction('/HUD/Bender/killAllHumans'); }); $("#HUDRemoveActions").click(function(){ Unity.clearActions(); }); } function initializeUnityAPI () { var name = "BigUnityWebTest"; var iconUrl = "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_business/pictograms-cloud.png"; function init() { addNotificationTests(); addIndicatorTests(); addMediaPlayerTests(); addLauncherTests(); addHUDTest(); } Unity.init ({ name: name, iconUrl: iconUrl, onInit: init }); } $().ready( function() { $("#initButton").click(initializeUnityAPI); }); unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/0000755000015301777760000000000012320723226023531 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/api-bindings.pro0000644000015301777760000000037612320722666026634 0ustar pbusernogroup00000000000000TEMPLATE = aux SUBDIRS= QML_IN_FILES = $$system(ls ./*/*.qml.in) OTHER_FILES += \ $$QML_IN_FILES \ $$system(ls ./*/www/*.html) \ $$system(ls ./*/www/js/*.js) QMAKE_SUBSTITUTES += $$QML_IN_FILES OTHER_FILES += \ $$system(ls ./*/*.qml) unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub/0000755000015301777760000000000012320723226025757 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub/main.qml.in0000644000015301777760000000124612320722666030035 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.UnityWebApps 0.1 MainView { id: root focus: true applicationName: \"helloworld\" width: units.gu(100) height: units.gu(100) WebView { id: webview anchors.fill: parent url: \"file://$$OUT_PWD/content-hub/www/index.html\" experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); } UnityWebApps { id: webapps bindee: webview } } } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub/www/0000755000015301777760000000000012320723226026603 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub/www/js/0000755000015301777760000000000012320723226027217 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub/www/js/app.js0000644000015301777760000001230012320722666030340 0ustar pbusernogroup00000000000000window.onload = function() { var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var transferState = hub.ContentTransfer.State; var pictureContentType = hub.ContentType.Pictures; var sourcePeers = {}; hub.getPeers( {contentType: hub.ContentType.Pictures} , function (peers) { if ( ! peers.length) return; for (var j = 0; j < peers.length; ++j) { addPeerElement(peers[j].appId(), peers[j].name()); sourcePeers[peers[j].appId()] = peers[j]; } document.getElementById('importdiv').style.display = 'block'; document.getElementById('lowLevelImportdiv').style.display = 'block'; }); document.getElementById('import').addEventListener('click', doSimpleApiImport); document.getElementById('lowLevelImport').addEventListener('click', doLowLevelImport); function addPeerElement(appId, name) { var peers = document.querySelector('#known-peers ul'); var li = document.createElement('li'); var span = document.createElement('span'); var text = document.createTextNode('appId: ' + appId + ', name: ' + name) span.appendChild(text); li.appendChild(span); li.addEventListener('click', function (e) { li.classList.toggle('selected'); }); li.setAttribute('data-appid', appId); peers.appendChild(li); }; var results = []; function addResult(item) { results.push({name: item.name, url: item.url}); renderResults(results); }; function displayImages(images) { var res = document.getElementById('results'); for (var i = 0; i < images.length; ++i) { var img = document.createElement('img'); img.setAttribute('src', images[i].url); img.setAttribute('height', '100px'); img.setAttribute('width', '100px'); if (images[i].name && images[i].name.length !== 0) img.setAttribute('alt', images[i].name); res.appendChild(img); } }; function aborted() { setResults('Transfer aborted'); }; function nopeers() { setResults('No peers found'); }; function selectonlyonepeer() { setResults('Please select only one peer'); }; function pleaseselectonepeer() { setResults('Please select one peer'); }; function setResults(results) { var resultEl = document.getElementById('results'); resultEl.innerHTML = results; }; function formatResults(results) { var content = '
    '; for (var i = 0; i < results.length; ++i) { content += '
  • ' + results[i].name + ', ' + results[i].url + '
  • '; } content += '
'; return content; }; function renderResults(results) { setResults(formatResults(results)); displayImages(results); }; function doSimpleApiImport() { var peers = document.querySelectorAll('#known-peers ul li.selected'); if (peers.length > 1) { selectonlyonepeer(); return; } if (peers.length === 0) { pleaseselectonepeer(); return; } var peer = sourcePeers[peers[0].getAttribute('data-appid')]; if (! peer) { return; } hub.api.importContent(pictureContentType , peer , {scope: hub.ContentScope.App} , function(items) { for (var i = 0; i < items.length; ++i) { addResult(items[i]); } } , function() { aborted(); }); }; function doLowLevelImport() { var peers = document.querySelectorAll('#known-peers ul li.selected'); if (peers.length > 1) { selectonlyonepeer(); return; } if (peers.length === 0) { pleaseselectonepeer(); return; } var peer = sourcePeers[peers[0].getAttribute('data-appid')]; if (! peer) { return; } hub.getStore(hub.ContentScope.App, function(store) { peer.requestForStore(store, function(transfer) { transfer.start(function(state) { if (transferState.Aborted === state) { transfer.finalize(); peer.destroy(); transfer.destroy(); aborted(); return; } if (transferState.Charged === state) { transfer.items(function(items) { for (var i = 0; i < items.length; ++i) { addResult(items[i]); } transfer.finalize(); peer.destroy(); transfer.destroy(); }); } }); }); }); }; }; unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub/www/index.html0000644000015301777760000000177012320722666030614 0ustar pbusernogroup00000000000000 Content Hub example
Known source peers (click on one and only one of them to set as the target of the import):
Results:
unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/online-accounts/0000755000015301777760000000000012320723226026632 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/online-accounts/main.qml.in0000644000015301777760000000120412320722666030702 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.UnityWebApps 0.1 Item { id: root focus: true width: units.gu(100) height: units.gu(100) WebView { id: webview anchors.fill: parent url: \"file://$$OUT_PWD/online-accounts/www/index.html\" experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); } UnityWebApps { id: webapps bindee: webview } } } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/online-accounts/www/0000755000015301777760000000000012320723226027456 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/online-accounts/www/js/0000755000015301777760000000000012320723226030072 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/online-accounts/www/js/app.js0000644000015301777760000000364012320722666031222 0ustar pbusernogroup00000000000000window.onload = function() { document.getElementById('refreshAccounts').addEventListener('click', listAccounts); var api = external.getUnityObject('1.0'); var oa = api.OnlineAccounts; function listAccounts() { var filters = {}; var service = document.getElementById('service').value; if (service) { filters['service'] = service } var provider = document.getElementById('provider').value; if (provider) { filters['provider'] = provider } oa.api.getAccounts(filters, function(accounts) { var ul = document.querySelector('#accounts ul'); if (accounts.length === 0) { var li = document.createElement('li'); li.appendChild(document.createTextNode('No accounts found')); ul.appendChild(li); } else { for(var i = 0; i < accounts.length; ++i) { var li = document.createElement('li'); li.innerHTML = 'id: ' + accounts[i].accountId() + ', name: ' + accounts[i].displayName() + ', provider: ' + JSON.stringify(accounts[i].provider()) + ', service: ' + JSON.stringify(accounts[i].service()); ul.appendChild(li); (function(i) { function authcallback(results) { setResults('Authentication result: ' + JSON.stringify(results)); }; li.addEventListener('click', function() { accounts[i].authenticate(authcallback); }); })(i); } } }); } function setResults(data) { var results = document.getElementById('results'); results.innerHTML += data; }; }; unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/online-accounts/www/index.html0000644000015301777760000000135712320722666031470 0ustar pbusernogroup00000000000000 Content Hub example
Results:
Provider: Service:
Accounts (click on an account to authenticate):
unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/0000755000015301777760000000000012320723226027625 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub/0000755000015301777760000000000012320723226032053 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017400000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub/content-hub-html5-exporter.jsonunity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub/content-0000644000015301777760000000005512320722666033534 0ustar pbusernogroup00000000000000{ "source": [ "pictures" ] } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/main.qml.in0000644000015301777760000000121112320722666031673 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.UnityWebApps 0.1 Item { id: root focus: true width: units.gu(100) height: units.gu(100) WebView { id: webview anchors.fill: parent url: \"file://$$OUT_PWD/content-hub-exporter/www/index.html\" experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); } UnityWebApps { id: webapps bindee: webview } } } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/www/0000755000015301777760000000000012320723226030451 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/www/js/0000755000015301777760000000000012320723226031065 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/www/js/app.js0000644000015301777760000000172112320722666032213 0ustar pbusernogroup00000000000000window.onload = function() { var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var transferState = hub.ContentTransfer.State; function _exportRequested(transfer) { log('Received an export request'); var url = window.location.href; url = url.substr(0, url.lastIndexOf('/')+1) + 'img/ubuntuone-music.png'; log('item url: ' + url); transfer.setItems([{name: 'Ubuntu One', url: url}], function() { log('The items have been set in the ContentTransfer'); transfer.setState(hub.ContentTransfer.State.Charged); log('State set to "Charged"'); }); }; hub.onExportRequested(_exportRequested); function log(content) { var resultEl = document.getElementById('results'); resultEl.innerHTML = resultEl.innerHTML + '
' + content; }; }; unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/www/img/0000755000015301777760000000000012320723226031225 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/www/img/ubuntuone-music.pngunity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/www/img/ubuntuone-mu0000644000015301777760000002176212320722666033632 0ustar pbusernogroup00000000000000PNG  IHDR>asBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<#oIDATx}idWuw}[fm]K6L#!l#B@1l03 `a%b,',2 BZ-ZjIz-3_wϙo|YRԍ9;|{-vmvl+vVm[۶lmn 0@#"@ێVmgȱ*=TV)E궫>;^{/ն۲=ʲgllaYֽoۯ}}UaRwot~d"R0 ھ@qښ-~ e[>1u>*5ģo+.7nJFEB'Tiq_&82n;i?w*55[_{^n`DE#%V* 'M[N~}n A@p9롭HL YƒT?*Or^ǗGZ:_ssN;?V}EN)@|Nvww  "@7]7ڿWs4`;} ұuNy|+*]ulK^%MlasνSe/K>^]@U9\9>ƛg?HD6@p:se+瀕3 f{!@|xJA@Y#XrMj풷N(ESH~)87q} 5`y8KGSon,<9KKg_Xv†r -xBca'wKa@c2z畗|x@}W?mߧU ,< >6Aq_?(srnțBE}^h_+ *ϤpgY^gl1*ڤӣ |{|'ԙ3kp;Hm7@;8蓒7$X.! ^;yA=B5҄>c!8^!R(@2 kTN3n?^dKy1 ]R^B|2t|ח Rm/ '['} O-z4 4c8>a80QWimp&fp$aJWA=!.]xbM#k a+(=D Hh0a)_9[ph{WM!R rR blPK.O@&.|}Q㻫6NH_<)5{4렦78e9|y.ߥ SB)UςoYYzm0v Ն 6"|Qh gB3¹PwqO3gNx^ύkf%J#RE=xҳ{9:ث[Z%ǜ YV4)(Q ,A#d N45~qr cM||M 7i]M݁ xq<1AYO SϲZ4Qt,Qj5y')f`'6N6j<“w^pƫ/vYx,R b^ z%c[*Mj븥IRV7_A`ƴYw0?i3~x-x 0a;'=x(jĊFlz } XS {0Vc˝Z :jhuq`k[5Kcʱ37%!T};СiLڪKpo._& EEV=|ߎ,\oY{; ~pbt,Œb']y|-*ՇH2 bNƟl {$v gq`d5[C{gCj b5v-8nO^e>hvt}e^ 9e^߸->T++EYںK |LX.Zh/`!?| ޾,K 0+ݹ $W!nߥQ@"HTl [gYBohumE]pFb^"sOh(kWA{q}z~6,}3>~zSqec+C;oph*u3qWahb3-,y _ ndROD`-7T-ȽUD#i2;lb8elF@b9AuaBUO!(AwWe蘮5A0kSSS "Z-MYro 3jC׵6S1f4k>qt !cRjs\g&|G0hySgk-̉BMzS r/. E*DN LZ 5\$>y\f1 rHwEI $qmAXon`=4rWޱu{X )Q1"k @+ ۧ7))iPՀqFz;ks4$꜂:[3{AXngH"O  N5*RD Rhہs;\\?!ztw/ &!>wxjaV{S"GHQ )M?!\ٰA1*'[UpDf `Y#DXע&CYֲ«w?WC+c<_ǧ8gQh^ RE(tZ j@E@C qjN -&x* W ሯK3vUk ZQaމgփ SNzܳ '˲a"RhSZk,"VuŰHu[F\c\PWG(Q^yſ޵ 7 5 Ai3m•n;7, 4X)%Ep?L0iwjNJa 囷0 !!h!Jh aTAWY;*ih8`3 t3"0̘c."qdoLv D"N> ;5@bn.7mbr2^Z .(B;(XقEgWDž2zz0qܹ.s(y vi(˥}yo1rE MsC.b1e ~t=-*mSzUp{#Fɦҫf/L:o6P?^lbBq[.4pe{δB@B`S!2 rH V'l"άwDtz[KO3oZ9jF<=E&+]Ӂ!^``LFĉt!X@ 97*(QEM``/m"7u5"jHY;l<R7JaIM*)X3(0t\Atuhd`!aU$h2d10R 4kcŸfRby`Ғn Єww/E#@1tUJAxcB, H nsQp,V̟=I!hkԂa4탹{ dSWOh]Y qջ,}>IV#>cƟ:ݽ] - 6eJ__e(4lǕ@cc8 wW,'D>`Ӛ _W.xQt7!ZU28# \:=T ;jaxXeXTY?6*uW\;!^KL7h-|oW=rq6G$PHo] W4mr^n7b\i }.$bP褬=+ wDO c:7UQ%ӣ GôSd˘=M Jx$x'Tz0idrA |HG{GOcRQ/a3¼Ű,ʙʦO >&' G؊0e+ œ+j- Prip x#"Mi w,EӖ WA+,S~)=E1@)h^Z,(YG9.~ͧxm"*dk28蹲nC!Z̦GC[Ҭ=γΉGAf?j^ &*1o ׁ$UԡDulD`022L Y'H4+NXK}+^꼥@'~| wӍcB`}`wD Ca9b(DְVٖ=D |$ZmR{^exN5)>Fbq\L[/UD!} QY W <h/;9X`%=ݒmㆃA`1Y 8ƍm,`^H ~ ,%7qocsu>B&pTX<`$l00^%}6fWq"w0i!!b4.kwqohȴp|qLVz/n%(G~٬_WqC-_c"Q銟>&$*ó!Arcw)=  x6\z?Xzهc+ J{xϴPs">O9v[\_C Z),V!gcӨ!`/(q^W _/xob*+ +>6!֟~Gq,?~jL ܟdTq.HfI)؊q݄{ނj3OawbC9nen.cQ,ˏX=C$ >Z ϳR@[~_LŒT MO@C3Z{?߸^]7]5ڮy83sٲ Z gZ83YΟFs!zOF,hI0o)L,r(hw2Z.v֫"~F.غL em܃ |gSx;YW0 UFu:0J$ӫHmX-V]r $Cʖ,G jJcM#a&Q49\&6A'+2B%x:w$o * G.UiMKVo$`QѪ#&OfPY:{?R6JJ*L<V(Qد UDvbպ]| KsN* +[+hּ?:ʾJj..-y-+{BmT-M.B W&)R4ozXy?2UH޽[[[s S.XY.| V5dnHp۶f/>$Z,m}9p@HD^JXV^j`\ٞSff3sxg[ yQD n!h[H]zqb9Cg8ahMOOku52-WMD}{C>Gam1`<Orr\RJ)&]|lUiR_;p =;L,> "{g|H[>zWx=1]ُo%mhc~C0p]׬\J "BDf߾}8* E9ե Content Hub Exporter example
Log:
././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub-html5-exporter.jsonunity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub-html5-ex0000644000015301777760000000025412320722666033447 0ustar pbusernogroup00000000000000{ "template": "unconfined", "policy_groups": [ "networking", "content_exchange_source", "content_exchange" ], "policy_version": 1 } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/manifest.json0000644000015301777760000000112312320722666032332 0ustar pbusernogroup00000000000000{ "description": "An example of a Content Hub exporter HTML5 application", "framework": "ubuntu-sdk-13.10", "hooks": { "content-hub-html5-exporter": { "apparmor": "content-hub-html5-exporter.json", "content-hub": "content-hub/content-hub-html5-exporter.json", "desktop": "content-hub-html5-exporter.desktop" } }, "name": "com.ubuntu.developer.alexandre-abreu.content-hub-html5-exporter", "title": "content-hub-html5-exporter", "maintainer": "Alexandre Abreu ", "version": "0.1" } ././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub-html5-exporter.desktopunity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/content-hub-html5-ex0000644000015301777760000000032612320722666033447 0ustar pbusernogroup00000000000000[Desktop Entry] Name=content-hub-html5-exporter Comment=Content Hub HTML5 Exporter application Exec=/usr/bin/ubuntu-html5-app-launcher $@ --www=www Icon=qmlscene Terminal=false Type=Application X-Ubuntu-Touch=true unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-hub-exporter/README0000644000015301777760000000141112320722666030511 0ustar pbusernogroup00000000000000# make sure that you have the latest upstart app launch installed # I found that it was better to kill the content-hub-service and let it restart itself # since I saw some instances where it didn't pick up the new content hub source peer. click build . pkcon install-local com.ubuntu.developer.alexandre-abreu.content-hub-html5-exporter_0.1_all.click sudo click install --user=$USER com.ubuntu.developer.alexandre-abreu.content-hub-html5-exporter_0.1_all.click # make sure that you have a symbolic link in ~/.local/share/content-hub. It should be the same name as the APP_ID: # com.ubuntu.developer.alexandre-abreu.content-hub-html5-exporter_content-hub-html5-exporter_0.1 # and point to the content-hub-exporter.json file. unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/runtime-api/0000755000015301777760000000000012320723226025763 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/runtime-api/main.qml.in0000644000015301777760000000124712320722666030042 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.UnityWebApps 0.1 MainView { id: root focus: true applicationName: \"runtime-api\" width: units.gu(100) height: units.gu(100) WebView { id: webview anchors.fill: parent url: \"file://$$OUT_PWD/runtime-api/www/index.html\" experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); } UnityWebApps { id: webapps bindee: webview } } } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/runtime-api/www/0000755000015301777760000000000012320723226026607 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/runtime-api/www/js/0000755000015301777760000000000012320723226027223 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/runtime-api/www/js/app.js0000644000015301777760000000350012320722666030346 0ustar pbusernogroup00000000000000window.onload = function() { function setResult(message) { var results = document.getElementById('results'); results.innerHTML += message + '
'; } var last = 0; if (localStorage.getItem("lastkilled") !== null) last = localStorage.getItem("lastkilled"); setResult('last killed: ' + last); var api = external.getUnityObject('1.0'); api.RuntimeApi.getApplication(function(application) { setResult('application name: ' + application.getApplicationName()); setResult('application info: ' + JSON.stringify(application.getPlatformInfo())); var inputMethodName = application.getInputMethodName(); if (inputMethodName.length === 0) setResult('input method: no OSK available'); else setResult('input method: ' + inputMethodName); setResult('screen orientation: ' + application.getScreenOrientation()); application.onScreenOrientationChanged(function(name) { setResult('Event: orientation changed - ' + name); }); application.onAboutToQuit(function(killed) { localStorage.setItem("lastkilled", last + 1); console.log('killed: ' + killed) setResult('onAboutToQuit: ' + killed); }); application.onDeactivated(function() { setResult('Event: application deactivated'); }); application.onActivated(function() { setResult('Event: application activated'); }); application.onInputMethodVisibilityChanged(function(visibility) { setResult('Event: onInputMethodVisibilityChanged - ' + visibility); }); application.setupUriHandler(function(uris) { setResult('Event: received URI to open w/ UriHandler - ' + JSON.stringify(uris)); }); }); }; unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/runtime-api/www/index.html0000644000015301777760000000052012320722666030610 0ustar pbusernogroup00000000000000 Runtime Api example
Results:
unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-peer-picker/0000755000015301777760000000000012320723226027407 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-peer-picker/main.qml.in0000644000015301777760000000124612320722666031465 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.UnityWebApps 0.1 MainView { id: root focus: true applicationName: \"helloworld\" width: units.gu(100) height: units.gu(100) WebView { id: webview anchors.fill: parent url: \"file://$$OUT_PWD/content-hub/www/index.html\" experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); } UnityWebApps { id: webapps bindee: webview } } } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-peer-picker/www/0000755000015301777760000000000012320723226030233 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-peer-picker/www/js/0000755000015301777760000000000012320723226030647 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-peer-picker/www/js/app.js0000644000015301777760000000547312320722666032005 0ustar pbusernogroup00000000000000window.onload = function() { var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var transferState = hub.ContentTransfer.State; var pictureContentType = hub.ContentType.Pictures; document.getElementById('pick').addEventListener('click', doContentPeerPicking); function doContentPeerPicking() { hub.launchContentPeerPicker( { contentType: hub.ContentType.Pictures, handler: hub.ContentHandler.Source, }, function(peer) { if ( ! peer) { nopeers(); return; } addPeerElement(peer.appId(), peer.name()); doSimpleApiImport(peer); }, function() { aborted(); }); }; function addPeerElement(appId, name) { var selectedpeer = document.querySelector('#selected-peer'); var span = document.createElement('span'); var text = document.createTextNode('appId: ' + appId + ', name: ' + name) span.appendChild(text); selectedpeer.appendChild(span); }; var results = []; function addResult(item) { results.push({name: item.name, url: item.url}); renderResults(results); }; function displayImages(images) { var res = document.getElementById('results'); for (var i = 0; i < images.length; ++i) { var img = document.createElement('img'); img.setAttribute('src', images[i].url); img.setAttribute('height', '100px'); img.setAttribute('width', '100px'); if (images[i].name && images[i].name.length !== 0) img.setAttribute('alt', images[i].name); res.appendChild(img); } }; function aborted() { setResults('Transfer aborted'); }; function nopeers() { setResults('No peers found'); }; function setResults(results) { var resultEl = document.getElementById('results'); resultEl.innerHTML = results; }; function formatResults(results) { var content = '
    '; for (var i = 0; i < results.length; ++i) { content += '
  • ' + results[i].name + ', ' + results[i].url + '
  • '; } content += '
'; return content; }; function renderResults(results) { setResults(formatResults(results)); displayImages(results); }; function doSimpleApiImport(peer) { hub.api.importContent(pictureContentType , peer , {scope: hub.ContentScope.App} , function(items) { for (var i = 0; i < items.length; ++i) { addResult(items[i]); } } , function() { aborted(); }); }; }; unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/content-peer-picker/www/index.html0000644000015301777760000000077612320722666032251 0ustar pbusernogroup00000000000000 Content Hub: Content Peer Picker example
Start Content Peer picking to import content:
Selected peer:
Imported Image:
unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/alarm/0000755000015301777760000000000012320723226024625 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/alarm/main.qml.in0000644000015301777760000000117212320722666026701 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Components 0.1 import Ubuntu.UnityWebApps 0.1 Item { id: root focus: true width: units.gu(100) height: units.gu(100) WebView { id: webview anchors.fill: parent url: \"file://$$OUT_PWD/alarm/www/index.html\" experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); } UnityWebApps { id: webapps bindee: webview } } } unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/alarm/www/0000755000015301777760000000000012320723226025451 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/alarm/www/js/0000755000015301777760000000000012320723226026065 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/alarm/www/js/app.js0000644000015301777760000000277712320722666027227 0ustar pbusernogroup00000000000000window.onload = function() { document.getElementById('start') .addEventListener('click', doStart); function getDate() { var datetime = document.getElementById('date').value; if (! datetime || datetime.length == 0) return null; var parts = datetime.split('T'); if (! parts || parts.length != 2) return null; var calendar = parts[0]; var time = parts[1]; parts = calendar.split('-'); if (! parts || parts.length != 3) return null; var date = new Date(parts[0], parts[1] - 1, parts[2]); var times = time.split(':'); if ( ! times || times.length != 3) return date; date.setHours(times[0]); date.setMinutes(times[1]); date.setSeconds(times[2]); return date; } function doStart() { var api = external.getUnityObject('1.0'); var date = getDate(); if ( ! date) { var results = document.getElementById('results'); results.innerHTML = "Invalid date"; return; } api.AlarmApi.api.createAndSaveAlarmFor( date, api.AlarmApi.AlarmType.OneTime, api.AlarmApi.AlarmDayOfWeek.AutoDetect, document.getElementById('message').value, function(errorid) { var results = document.getElementById('results'); results.innerHTML = api.AlarmApi.api.errorToMessage(errorid); }); }; }; unity-webapps-qml-0.1+14.04.20140408/examples/api-bindings/alarm/www/index.html0000644000015301777760000000114512320722666027456 0ustar pbusernogroup00000000000000 Content Hub example
Date (expected format YYYY-MM-DDThh:mm:ss, e.g. 2014-01-22T23:44:16):
Message:
Start:
Results:
unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-qml-model-example.desktop0000644000015301777760000000057112320722666030717 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Exec=qmlscene /usr/share/unity-webapps-qml/examples/webapps-app-model/main.qml Path=/usr/share/unity-webapps-qml/examples/webapps-apps-model Name=Unity WebApp QML Comonent - Example of WebApps Applications Model GenericName=Unity WebApp QML Comonent for Ubuntu Example of WebApps Applications Model Icon=drive-multidisk-symbolic Terminal=false unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-example-bbcnews/0000755000015301777760000000000012320723226027046 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-example-bbcnews/main.qml0000644000015301777760000000323612320722666030520 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Window 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.UnityWebApps 0.1 Window { width: 640 height: 640 WebView { id: webView anchors.fill: parent width: parent.width height: parent.height experimental.userScripts: [] experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true experimental.userAgent: { return "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" } function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); } UnityWebApps { id: webapps name: "BBCNews" bindee: webView model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'} } } } unity-webapps-qml-0.1+14.04.20140408/examples/basic-webview/0000755000015301777760000000000012320723226023714 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/basic-webview/main.qml0000644000015301777760000000257112320722666025367 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtQuick.Window 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.UnityWebApps 0.1 Window { width: 640 height: 640 WebView { id: webView // test url url: "file:///usr/share/unity-webapps-qml/examples/data/html/big-test.html" anchors.fill: parent experimental.userScripts: [] experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true experimental.userAgent: { return "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" } experimental.onMessageReceived: { var msg = null try { msg = JSON.parse(message.data) } catch (error) { console.debug('DEBUG:', message.data) return } } function getUnityWebappsProxies() { var proxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); // override the default navigate to request proxies.navigateTo = function(url) {}; return proxies; } UnityWebApps { id: webapps name: "BBCNews" bindee: webView model: UnityWebappsAppModel { } } } } unity-webapps-qml-0.1+14.04.20140408/examples/webapps-app-model/0000755000015301777760000000000012320723226024502 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/examples/webapps-app-model/main.qml0000644000015301777760000000112412320722666026146 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtQuick.Window 2.0 import Ubuntu.UnityWebApps 0.1 Window { id: rootItem width: 360 height: 360 ListView { id: webapps anchors.fill: parent model: UnityWebappsAppModel {} delegate: installedWebappsDelegate Component { id: installedWebappsDelegate Item { width: 180; height: 40 Column { Text { text: 'Name: ' + name } Text { text: 'Domain: ' + domain } } } } } } unity-webapps-qml-0.1+14.04.20140408/examples/unity-webapps-qml-bbcnews-example.desktop0000644000015301777760000000063412320722666031242 0ustar pbusernogroup00000000000000[Desktop Entry] Name=BBCNewsWebappsQMLExample Type=Application Exec=/usr/bin/unity-webapps-qml-launcher --qml=/usr/share/unity-webapps-qml/examples/unity-webapps-example-bbcnews/main.qml --app-id=unity-webapps-qml-bbcnews-example Path=/usr/share/unity-webapps-qml/examples/unity-webapps-example-bbcnews GenericName=Unity WebApp QML Component for Ubuntu Example using BBCNews binding Icon=qmlscene Terminal=false unity-webapps-qml-0.1+14.04.20140408/coverage.pri0000644000015301777760000000355512320722666021675 0ustar pbusernogroup00000000000000# 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 } unity-webapps-qml-0.1+14.04.20140408/tests/0000755000015301777760000000000012320723226020511 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/tests.pro0000644000015301777760000000005612320722666022405 0ustar pbusernogroup00000000000000TEMPLATE=subdirs SUBDIRS = unit integration unity-webapps-qml-0.1+14.04.20140408/tests/integration/0000755000015301777760000000000012320723226023034 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/0000755000015301777760000000000012320723226025054 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/setup.py0000644000015301777760000000112612320722666026575 0ustar pbusernogroup00000000000000#!/usr/bin/python # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # Copyright 2013 Canonical # # 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. from distutils.core import setup from setuptools import find_packages setup( name='unity-webapps-qml', version='0.1', description='Unity WebApps QML component autopilot tests.', url='https://launchpad.net/unity-webapps-qml', license='GPLv3', packages=find_packages(), ) unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/autopilot.pro0000644000015301777760000000035312320722666027626 0ustar pbusernogroup00000000000000TEMPLATE=aux OTHER_FILES += \ $$system(ls ./qml/*) \ $$system(ls ./html/*) \ $$system(ls ./unity_webapps_qml/emulators/*.py) \ $$system(ls ./unity_webapps_qml/tests/*.py) \ $$system(ls ./data/installed-webapps/*) unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/0000755000015301777760000000000012320723226030616 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/0000755000015301777760000000000012320723226031760 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/__init__.py0000644000015301777760000000756512320722666034115 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # Copyright 2013 Canonical # # 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. """unity-webapps-qml autopilot tests.""" import os import os.path import shutil import tempfile import json from testtools.matchers import Contains, Equals, GreaterThan from autopilot.matchers import Eventually from unity.emulators.unity import Unity from unity.tests import UnityTestCase class UnityWebappsTestCaseBase(UnityTestCase): LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../../tools/qml-launcher/unity-webapps-qml-launcher') INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher' # TODO create __init__.py.in LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml') INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml' BASE_URL = '' def create_file_url(self, path): return 'file://' + path def get_qml_browser_container_path(self): if os.path.exists(self.LOCAL_BROWSER_CONTAINER_PATH): return self.LOCAL_BROWSER_CONTAINER_PATH return self.INSTALLED_BROWSER_CONTAINER_PATH def get_qml_launcher_path(self): if os.path.exists(self.LOCAL_QML_LAUNCHER_APP_PATH): return self.LOCAL_QML_LAUNCHER_APP_PATH return self.INSTALLED_QML_LAUNCHER_APP_PATH def get_launch_params(self, url): base_params = ['--qml=' + self.get_qml_browser_container_path(), '--url=' + url, '--app-id=unitywebappsqmllauncher', '--webappName=unitywebappsqmllauncher'] if os.path.exists(self.LOCAL_QML_LAUNCHER_APP_PATH): # we are local base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)), '../../../../../src')) return base_params def launch_with_html_filepath(self, html_filepath): self.assertThat(os.path.exists(html_filepath), Equals(True)) url = self.create_file_url(html_filepath) params = self.get_launch_params(url) print 'Launching test with params:', params self.app = self.launch_test_application(self.get_qml_launcher_path(), *params, app_type='qt') self.assert_url_eventually_loaded(url) self.webviewContainer = self.get_webviewContainer() self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)') def setUp(self): super(UnityWebappsTestCaseBase, self).setUp() def tearDown(self): super(UnityWebappsTestCaseBase, self).tearDown() def pick_app_launcher(self, app_path): # force Qt app introspection: from autopilot.introspection.qt import QtApplicationLauncher return QtApplicationLauncher() def get_webviewContainer(self): return self.app.select_single(objectName="webviewContainer") def get_webview(self): return self.app.select_single(objectName="webview") def get_title(self): return self.get_webview().title def assert_url_eventually_loaded(self, url): webview = self.get_webview() self.assertThat(webview.loadProgress, Eventually(Equals(100))) self.assertThat(webview.loading, Eventually(Equals(False))) self.assertThat(webview.url, Eventually(Equals(url))) def eval_expression_in_page_unsafe(self, expr): webview = self.get_webviewContainer() prev_emissions = self.watcher.num_emissions webview.slots.evalInPageUnsafe(expr) self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions))) return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result'] ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_mediaplayer.pyunity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_mediap0000644000015301777760000001226312320722666034214 0ustar pbusernogroup00000000000000#!/usr/bin/env python # Copyright 2013 Canonical # # 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. import os import time from gi.repository import Unity, GObject from testtools.matchers import Equals, GreaterThan, NotEquals from testtools import skipUnless from autopilot import platform from autopilot.matchers import Eventually from unity.emulators import ensure_unity_is_running from unity_webapps_qml.tests import UnityWebappsTestCaseBase class UnityWebappsMediaplayerTestCase(UnityWebappsTestCaseBase): LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_mediaplayer.html') INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_mediaplayer.html' def get_html_test_file(self): if os.path.exists(self.LOCAL_HTML_TEST_FILE): return os.path.abspath(self.LOCAL_HTML_TEST_FILE) return self.INSTALLED_HTML_TEST_FILE def setUp(self): super(UnityWebappsMediaplayerTestCase, self).setUp() # On Touch the dbus unity if does is not exposed if platform.model() == 'Desktop': ensure_unity_is_running() self.launch_with_html_filepath(self.get_html_test_file()) @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") def test_checkInitialSetTrack(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) expr = """ document.addEventListener('unity-webapps-do-call-response', function(e) { var response = e.detail; document.getElementById('status').innerHTML = '' + e.detail; }); var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['track']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('TXlBcnRpc3Q=;TXlUaXRsZQ==;TXlBbGJ1bQ=='))) @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") def test_checkInitialSetCanGoNext(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) expr = """ document.addEventListener('unity-webapps-do-call-response', function(e) { var response = e.detail; document.getElementById('status').innerHTML = '' + e.detail; }); var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-go-next']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true'))) @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") def test_checkInitialSetCanGoPrevious(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) expr = """ document.addEventListener('unity-webapps-do-call-response', function(e) { var response = e.detail; document.getElementById('status').innerHTML = '' + e.detail; }); var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-go-previous']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true'))) @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") def test_checkInitialSetCanPlay(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) expr = """ document.addEventListener('unity-webapps-do-call-response', function(e) { var response = e.detail; document.getElementById('status').innerHTML = '' + e.detail; }); var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-play']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true'))) unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_hud.py0000644000015301777760000000676112320722666034172 0ustar pbusernogroup00000000000000#!/usr/bin/env python # Copyright 2013 Canonical # # 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. import os import time from testtools.matchers import Equals, GreaterThan, NotEquals from autopilot.matchers import Eventually from autopilot import platform from unity.emulators.icons import HudLauncherIcon from unity.emulators import ensure_unity_is_running from unity_webapps_qml.tests import UnityWebappsTestCaseBase class UnityWebappsHudTestCase(UnityWebappsTestCaseBase): LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_hud.html') INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_hud.html' def get_html_test_file(self): if os.path.exists(self.LOCAL_HTML_TEST_FILE): return os.path.abspath(self.LOCAL_HTML_TEST_FILE) return self.INSTALLED_HTML_TEST_FILE def setUp(self): super(UnityWebappsHudTestCase, self).setUp() # On Touch the dbus unity if does is not exposed if platform.model() == 'Desktop': ensure_unity_is_running() self.launch_with_html_filepath(self.get_html_test_file()) def test_addAction(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded'))) self.unity.hud.ensure_visible() self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type("This is an action") self.keyboard.press_and_release("Enter") self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), Eventually(Equals('none'))) def test_clearAction(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded'))) expr = """ var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearAction', 'args': ['This is an action']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.unity.hud.ensure_visible() self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type("This is an action") self.keyboard.press_and_release("Enter") self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none')) def test_clearActions(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded'))) expr = """ var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearActions', 'args': []})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) actions = ['This is an action', 'Another action'] for action in actions: self.unity.hud.ensure_visible() self.addCleanup(self.unity.hud.ensure_hidden) self.keyboard.type(action) self.keyboard.press_and_release("Enter") self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none')) ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_launcher.pyunity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_launch0000644000015301777760000000721012320722666034223 0ustar pbusernogroup00000000000000#!/usr/bin/env python # Copyright 2013 Canonical # # 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. import os import time from gi.repository import Unity, GObject from testtools.matchers import Equals, GreaterThan, NotEquals from testtools import skipUnless from autopilot import platform from autopilot.matchers import Eventually from unity.emulators.icons import HudLauncherIcon from unity.emulators import ensure_unity_is_running from unity_webapps_qml.tests import UnityWebappsTestCaseBase class UnityWebappsLauncherTestCase(UnityWebappsTestCaseBase): LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_launcher.html') INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_launcher.html' def get_html_test_file(self): if os.path.exists(self.LOCAL_HTML_TEST_FILE): return os.path.abspath(self.LOCAL_HTML_TEST_FILE) return self.INSTALLED_HTML_TEST_FILE def setUp(self): super(UnityWebappsLauncherTestCase, self).setUp() # On Touch the dbus unity if does is not exposed if platform.model() == 'Desktop': ensure_unity_is_running() self.launch_with_html_filepath(self.get_html_test_file()) @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") def test_checkCounts(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('launcher-updated'))) launcher_icon = self.unity.launcher.model.get_icon(desktop_id='unitywebappsqmllauncher.desktop') self.assertThat(launcher_icon, NotEquals(None)) expr = """ document.addEventListener('unity-webapps-do-call-response', function(e) { var response = e.detail; document.getElementById('status').innerHTML = '' + e.detail; }); var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'Launcher.__get', 'with_callback': true, 'args': ['count']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('42'))) # self.assertThat(launcher.get_property('progress'), Equals(0.09375)) @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") def test_checkProgress(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('launcher-updated'))) launcher_icon = self.unity.launcher.model.get_icon(desktop_id='unitywebappsqmllauncher.desktop') self.assertThat(launcher_icon, NotEquals(None)) expr = """ document.addEventListener('unity-webapps-do-call-response', function(e) { var response = e.detail; document.getElementById('status').innerHTML = '' + e.detail; }); var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'Launcher.__get', 'with_callback': true, 'args': ['progress']})}); document.dispatchEvent (e); return true; """ self.eval_expression_in_page_unsafe(expr) self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('0.09375'))) ././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.pyunity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/tests/test_inject0000644000015301777760000000701012320722666034223 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # Copyright 2013 Canonical # # 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. from __future__ import absolute_import import time import os from testtools.matchers import Equals, GreaterThan, NotEquals from autopilot.matchers import Eventually from unity_webapps_qml.tests import UnityWebappsTestCaseBase class UnityWebappsApiInjectedTestCaseBase(UnityWebappsTestCaseBase): LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_api_injected.html') INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_api_injected.html' def get_html_test_file(self): if os.path.exists(self.LOCAL_HTML_TEST_FILE): return os.path.abspath(self.LOCAL_HTML_TEST_FILE) return self.INSTALLED_HTML_TEST_FILE def setUp(self): super(UnityWebappsApiInjectedTestCaseBase, self).setUp() self.launch_with_html_filepath(self.get_html_test_file()) def test_getUnityObjectFound(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None))) def test_actionsApiFound(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None))) expression = """ var unity = window.external.getUnityObject(1.0); return unity.addAction != null && unity.clearAction && unity.clearActions != null; """ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None))) def test_notificationApiFound(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None))) expression = """ var unity = window.external.getUnityObject(1.0); return unity.Notification != null && unity.Notification.showNotification != null; """ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None))) def test_messagingIndicatorApiFound(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None))) expression = """ var unity = window.external.getUnityObject(1.0); return unity.MessagingIndicator != null && unity.MessagingIndicator.addAction != null && unity.MessagingIndicator.clearIndicator != null && unity.MessagingIndicator.clearIndicators != null && unity.MessagingIndicator.showIndicator != null; """ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None))) def test_ubuntuReadyEventSent(self): self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None))) expression = """ var api_ready_count = window.localStorage['ubuntu-webapps-api-ready-key']; return api_ready_count != null && api_ready_count > 0; """ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None))) unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/__init__.py0000644000015301777760000000055512320722666032743 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # Copyright 2013 Canonical # # 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. """unity-webapps-qml autopilot tests and emulators - top level package.""" unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/emulators/0000755000015301777760000000000012320723226032631 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/emulators/__init__.pyunity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/unity_webapps_qml/emulators/__init_0000644000015301777760000000044212320722666034163 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # Copyright 2013 Canonical # # 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. unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/0000755000015301777760000000000012320723226026020 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/test_webapps_api_injected.html0000644000015301777760000000022412320722666034111 0ustar pbusernogroup00000000000000 Unity Webapps QML test HELLO WORLD
unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/test_webapps_hud.html0000644000015301777760000000202612320722666032255 0ustar pbusernogroup00000000000000 Unity Webapps QML test: HUD HELLO WORLD

THE CONTENT IS VISIBLE

unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/test_webapps_launcher.html0000644000015301777760000000263512320722666033304 0ustar pbusernogroup00000000000000 Unity Webapps QML test: Launcher HELLO WORLD

THE CONTENT IS VISIBLE

unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/test_webapps_mediaplayer.html0000644000015301777760000000333712320722666033777 0ustar pbusernogroup00000000000000 Unity Webapps QML test: MediaPlayer HELLO WORLD

THE CONTENT IS VISIBLE

././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/test_webapps_messagingmenu.htmlunity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/html/test_webapps_messagingmenu.htm0000644000015301777760000000201612320722666034162 0ustar pbusernogroup00000000000000 Unity Webapps QML test: MessagingMenu HELLO WORLD

THE CONTENT IS VISIBLE

unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/qml/0000755000015301777760000000000012320723226025645 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/qml/injected-script.js0000644000015301777760000000214612320722666031304 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app 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 . */ (function () { var UBUNTU_WEBAPPS_API_READY_KEY = 'ubuntu-webapps-api-ready-key'; window.onload = function () { document.addEventListener('ubuntu-webapps-api-ready', function () { if ( ! window.localStorage[UBUNTU_WEBAPPS_API_READY_KEY]) { window.localStorage[UBUNTU_WEBAPPS_API_READY_KEY] = 0; } window.localStorage[UBUNTU_WEBAPPS_API_READY_KEY] ++; }); }; }) (); unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/qml/dom-introspection-utils.js0000644000015301777760000000251212320722666033025 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app 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 . */ function gentid() { return Math.random() + ''; } function wrapJsCommands(commands) { return '(function() { ' + commands + ' })();' } function createResult(result, tid) { return JSON.stringify({result: result, tid: tid}); } function dumpValue(v) { if (typeof(v) === "string") { return "'" + v + "'"; } return v; } function setupClosedVariables(variables) { var variableDeclStatements = ''; for (var variable in variables) { if (variables.hasOwnProperty(variable)) { variableDeclStatements += 'var ' + variable + ' = ' + dumpValue(variables[variable]) + ';'; } } return variableDeclStatements; } unity-webapps-qml-0.1+14.04.20140408/tests/integration/autopilot/qml/FullWebViewApp.qml0000644000015301777760000000514212320722666031225 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Window 2.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 import Ubuntu.Unity.Action 1.0 as UnityActions import Ubuntu.UnityWebApps 0.1 import "dom-introspection-utils.js" as DomIntrospectionUtils Window { id: root objectName: "webviewContainer" width: 640 height: 640 signal resultUpdated(string message) function evalInPageUnsafe(expr) { var tid = DomIntrospectionUtils.gentid(); webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr), function(result) { console.log('Result: ' + result); root.resultUpdated(DomIntrospectionUtils.createResult(result)); }); } property alias url: webView.url property string webappName: "" property string webappSearchPath: "" UnityActions.ActionManager { localContexts: [webappsActionsContext] } UnityActions.ActionContext { id: webappsActionsContext active: true } WebView { id: webView objectName: "webview" anchors.fill: parent width: parent.width height: parent.height experimental.userScripts: [Qt.resolvedUrl("injected-script.js")] experimental.preferences.navigatorQtObjectEnabled: true experimental.preferences.developerExtrasEnabled: true onLoadingChanged: console.debug('onLoadingChanged: loading changed: ' + loadRequest.url + ', status: ' + loadRequest.status) function getUnityWebappsProxies() { return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); } UnityWebApps { id: webapps objectName: "webappsContainer" actionsContext: webappsActionsContext name: root.webappName bindee: webView //searchPath: '/home/alex/dev/work/webapps/branches/webapps-qml/latest/examples/data/userscripts' model: UnityWebappsAppModel { } } } } unity-webapps-qml-0.1+14.04.20140408/tests/integration/test-server.py0000755000015301777760000000066112320722666025706 0ustar pbusernogroup00000000000000#!/usr/bin/env python import SocketServer import SimpleHTTPServer import urllib PORT = 8181 class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_GET(self): if self.path == '/': self.path = '/unity-integration.html' return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) httpd = SocketServer.TCPServer(('0.0.0.0', PORT), Proxy) print "serving at port", PORT httpd.serve_forever() unity-webapps-qml-0.1+14.04.20140408/tests/integration/integration.pro0000644000015301777760000000005012320722666026103 0ustar pbusernogroup00000000000000TEMPLATE = subdirs SUBDIRS = autopilot unity-webapps-qml-0.1+14.04.20140408/tests/unit/0000755000015301777760000000000012320723226021470 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/0000755000015301777760000000000012320723226024025 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/tst_manifestParser.h0000644000015301777760000000226712320722666030071 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __TST_MANIFEST_PARSER_H__ #define __TST_MANIFEST_PARSER_H__ #include #include #include class ManifestParserTest: public QObject { Q_OBJECT public: ManifestParserTest(); private Q_SLOTS: void initTestCase(); // tests void testParseManifest(); void testParseChromeOptions(); private: static QFileInfoList listManifests(const QDir& parent); static bool shouldManifestSucceed(const QString& filename); }; #endif // __TST_MANIFEST_PARSER_H__ unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/tst_webappsAppModel.h0000644000015301777760000000222212320722666030160 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __TST_WEBAPPS_APP_MODEL_H__ #define __TST_WEBAPPS_APP_MODEL_H__ #include #include #include class WebappsAppModelTest: public QObject { Q_OBJECT public: WebappsAppModelTest(); private Q_SLOTS: void initTestCase(); // tests void testEmptyWebappsModel(); void testWebappsModel(); void testWebappsContentWithRequiresModel(); void testWebappsModelUrlMatch(); private: }; #endif // __TST_WEBAPPS_APP_MODEL_H__ unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/test_plugin.pro0000644000015301777760000000227612320722666027122 0ustar pbusernogroup00000000000000include(../../../common-project-config.pri) TARGET = tst_plugin CONFIG += \ debug \ link_pkgconfig PKGCONFIG += glib-2.0 \ gio-2.0 QT += \ core \ qml \ testlib PLUGIN_SRC_DIR = \ $$TOP_SRC_DIR/src/Ubuntu/UnityWebApps/plugin SOURCES += \ tst_plugin.cpp \ tst_manifestParser.cpp \ tst_webappsAppModel.cpp \ $${PLUGIN_SRC_DIR}/unity-webapps-app-model.cpp \ $${PLUGIN_SRC_DIR}/unity-webapps-app-manifest-parser.cpp \ $${PLUGIN_SRC_DIR}/unity-webapps-desktop-infos.cpp \ $${PLUGIN_SRC_DIR}/abstract-item-model-adaptor.cpp \ main.cpp HEADERS += \ tst_plugin.h \ tst_manifestParser.h \ tst_webappsAppModel.h \ $${PLUGIN_SRC_DIR}/unity-webapps-app-model.h \ $${PLUGIN_SRC_DIR}/unity-webapps-desktop-infos.h \ $${PLUGIN_SRC_DIR}/abstract-item-model-adaptor.h \ $${PLUGIN_SRC_DIR}/unity-webapps-app-manifest-parser.h INCLUDEPATH += \ $$TOP_SRC_DIR/src/Ubuntu/UnityWebApps OTHER_FILES += \ $$system(ls ./data/*/*) \ $$system(ls ./data/*/*/*) \ $$system(ls *.sh) # manually add the 'check' target check.depends = $${TARGET} check.commands = "set -e; ./runtests.sh $${TARGET}" QMAKE_EXTRA_TARGETS += check unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/runtests.sh0000755000015301777760000000203112320722666026256 0ustar pbusernogroup00000000000000#!/bin/bash # # Copyright © 2013 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ################################################################################ set +e _CMD="" _TEST_FILE=$1 function create_test_cmd { _CMD="./$_TEST_FILE" } function execute_test_cmd { echo "Executing $_CMD" _FAILURES=$($_CMD | grep 'FAIL!' 2>&1) echo $_FAILURES if [ -z "$_FAILURES" ] then echo "OK." else echo "*** Failed tests." set -e exit -2 fi } create_test_cmd execute_test_cmd unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/0000755000015301777760000000000012320723226024736 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/0000755000015301777760000000000012320723226030354 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-valid/unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-val0000755000015301777760000000000012320723226033664 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016500000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-valid/manifest.jsonunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-val0000644000015301777760000000073212320722666033677 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news", "http://www.bbc.*/news/*"], "requires": ["utils.js"], "name": "BBCNews-valid", "scripts": ["valid.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3" } ././@LongLink0000000000000000000000000000016500000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-valid/valid.user.jsunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-val0000644000015301777760000000006312320722666033674 0ustar pbusernogroup00000000000000var Unity = window.external.getUnityObject('1.0'); unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/invalid/0000755000015301777760000000000012320723226032002 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/invalid/manifest.jsonunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/invalid/manifest.0000644000015301777760000000073412320722666033624 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "BBCNews-valid", "scripts": ["valid.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3" } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/invalid/valid.user.jsunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/invalid/valid.use0000644000015301777760000000006312320722666033625 0ustar pbusernogroup00000000000000var Unity = window.external.getUnityObject('1.0'); ././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-with-requires-valid/unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-wit0000755000015301777760000000000012320723226033705 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000020300000000000011210 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-with-requires-valid/manifest.jsonunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-wit0000644000015301777760000000074212320722666033721 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "with-requires-valid", "scripts": ["valid.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3" } ././@LongLink0000000000000000000000000000020300000000000011210 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-with-requires-valid/valid.user.jsunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/unity-webapps-wit0000644000015301777760000000006312320722666033715 0ustar pbusernogroup00000000000000var Unity = window.external.getUnityObject('1.0'); unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/common/0000755000015301777760000000000012320723226031644 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/installed-webapps/common/utils.js0000644000015301777760000000004712320722666033352 0ustar pbusernogroup00000000000000var trim = function (s) { return s; }; unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/0000755000015301777760000000000012320723226026727 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-chrome-backfw-and-no-chrome.jsonunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-chrome-backfw-and-n0000644000015301777760000000101012320722666033451 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "BBCNews", "scripts": ["BBCNews.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3", "chrome": "back-forward-buttons;no-chrome" } ././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-chrome-backfw-and-reload.jsonunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-chrome-backfw-and-r0000644000015301777760000000101412320722666033461 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "BBCNews", "scripts": ["BBCNews.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3", "chrome": "back-forward-buttons;reload-button" } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-chrome-backfw.json0000644000015301777760000000077612320722666033450 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "BBCNews", "scripts": ["BBCNews.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3", "chrome": "back-forward-buttons" } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-no-default-chrome.jsonunity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-no-default-chrome.j0000644000015301777760000000073012320722666033517 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "BBCNews", "scripts": ["BBCNews.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3" } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/manifests/valid-manifest.json0000644000015301777760000000073012320722666032534 0ustar pbusernogroup00000000000000{ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"], "requires": ["utils.js"], "name": "BBCNews", "scripts": ["BBCNews.user.js"], "maintainer": "Webapps Team ", "manifest-version": "1.0", "integration-version": "2.3", "package-name": "BBCNews", "icons": {"128":"128/unity-webapps-bbc.png"}, "domain":"bbc.co.uk", "homepage":"http://www.bbc.co.uk/news/", "license":"GPL-3" } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/data/no-installed-webapps/0000755000015301777760000000000012320723226030766 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/tst_plugin.h0000644000015301777760000000201012320722666026366 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef TST_PLUGIN_H #define TST_PLUGIN_H #include class PluginTest: public QObject { Q_OBJECT public: PluginTest(); private Q_SLOTS: void initTestCase(); // tests void testLoadPlugin(); void testInit(); void testAbstractItemModelAdaptor(); void testApplicationSignalHandler(); }; #endif // TST_PLUGIN_H unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/tst_webappsAppModel.cpp0000644000015301777760000001065412320722666030523 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "tst_webappsAppModel.h" #include #include #include #include #include #include #include #include #include "plugin/unity-webapps-app-model.h" namespace { QString VALID_INSTALLED_WEBAPPS_SEARCH_PATH = "./data/installed-webapps"; } WebappsAppModelTest::WebappsAppModelTest() :QObject(0) {} void WebappsAppModelTest::initTestCase() { } void WebappsAppModelTest::testEmptyWebappsModel() { UnityWebappsAppModel model; model.setSearchPath("./data/no-installed-webapps"); QVERIFY(model.rowCount() == 0); } void WebappsAppModelTest::testWebappsModel() { const int VALID_INSTALLED_WEBAPPS_COUNT = QDir(VALID_INSTALLED_WEBAPPS_SEARCH_PATH) .entryInfoList (QStringList("*-valid"), QDir::Dirs) .count(); UnityWebappsAppModel model; model.setSearchPath(VALID_INSTALLED_WEBAPPS_SEARCH_PATH); const int FOUND_COUNT = model.rowCount(); QCOMPARE(FOUND_COUNT, VALID_INSTALLED_WEBAPPS_COUNT); for (int i = 0; i < FOUND_COUNT; ++i) { QVariant d = model.data(model.index(i), UnityWebappsAppModel::Name); QVERIFY(d.canConvert(QVariant::String)); QVERIFY(d.toString().endsWith("-valid")); QVariant content = model.data(model.index(i), UnityWebappsAppModel::ScriptsContent); QVERIFY(content.canConvert(QVariant::String)); QVERIFY(!content.toString().isEmpty()); QVERIFY(!model.getDomainFor(d.toString()).isEmpty()); } } void WebappsAppModelTest::testWebappsContentWithRequiresModel() { const int VALID_INSTALLED_WEBAPPS_COUNT = QDir(VALID_INSTALLED_WEBAPPS_SEARCH_PATH) .entryInfoList (QStringList("*-valid"), QDir::Dirs) .count(); UnityWebappsAppModel model; model.setSearchPath(VALID_INSTALLED_WEBAPPS_SEARCH_PATH); const int FOUND_COUNT = model.rowCount(); QCOMPARE(FOUND_COUNT, VALID_INSTALLED_WEBAPPS_COUNT); bool requiresFound = false; for (int i = 0; i < FOUND_COUNT; ++i) { QVariant d = model.data(model.index(i), UnityWebappsAppModel::Name); QVERIFY(d.canConvert(QVariant::String)); QVERIFY(d.toString().endsWith("-valid")); if (d.toString() == "with-requires-valid") { QVariant content = model.data(model.index(i), UnityWebappsAppModel::ScriptsContent); QVERIFY(content.canConvert(QVariant::String)); QVERIFY(!content.toString().isEmpty()); QVERIFY(content.toString().contains("var trim = function (s) { return s; };")); requiresFound = true; break; } } QVERIFY(requiresFound); } void WebappsAppModelTest::testWebappsModelUrlMatch() { const int VALID_INSTALLED_WEBAPPS_COUNT = QDir(VALID_INSTALLED_WEBAPPS_SEARCH_PATH) .entryInfoList (QStringList("*-valid"), QDir::Dirs) .count(); UnityWebappsAppModel model; model.setSearchPath(VALID_INSTALLED_WEBAPPS_SEARCH_PATH); const int FOUND_COUNT = model.rowCount(); QCOMPARE(FOUND_COUNT, VALID_INSTALLED_WEBAPPS_COUNT); int i = 0; for (; i < FOUND_COUNT; ++i) { QString name = model.data(model.index(i), UnityWebappsAppModel::Name).toString(); if (name.compare("BBCNews-valid") != 0) continue; QVERIFY(model.doesUrlMatchesWebapp(name, "http://www.bbc.co.uk/news")); QVERIFY(model.doesUrlMatchesWebapp(name, "http://www.bbc.co.uk/news/extra/e")); QVERIFY(model.doesUrlMatchesWebapp(name, "http://www.bbc.com/news/extra/e")); QVERIFY( ! model.doesUrlMatchesWebapp(name, "http://www.bbc.com/sports/extra/e")); break; } QVERIFY(i != FOUND_COUNT); } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/tst_manifestParser.cpp0000644000015301777760000000635712320722666030430 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "tst_manifestParser.h" #include #include #include #include #include #include #include #include "plugin/unity-webapps-app-manifest-parser.h" namespace { const QString manifestsDataPath = "./data/manifests"; void verifyChrome(const QString & filename, const ManifestFileInfoOption & option) { if (! filename.contains("chrome")) { // regular validation, should default to no-chrome QVERIFY(option.value().chromeOptions.contains("no-chrome") && option.value().chromeOptions.count() == 1); return; } bool noChromePresent = filename.contains("no-chrome"); if (noChromePresent) { // no-chrome should override any other value QVERIFY(option.value().chromeOptions.contains("no-chrome") && option.value().chromeOptions.count() == 1); return; } if (filename.contains("backfw")) { QVERIFY(option.value().chromeOptions.contains("back-forward-buttons") && ! option.value().chromeOptions.contains("no-chrome")); } if (filename.contains("reload")) { QVERIFY(option.value().chromeOptions.contains("reload-button") && ! option.value().chromeOptions.contains("no-chrome")); } } } // namespace { ManifestParserTest::ManifestParserTest() :QObject(0) {} QFileInfoList ManifestParserTest::listManifests(const QDir& parent) { return parent.entryInfoList(QStringList("*.json"), QDir::Files); } bool ManifestParserTest::shouldManifestSucceed(const QString& filename) { return filename.startsWith("valid-"); } void ManifestParserTest::initTestCase() { } void ManifestParserTest::testParseManifest() { UnityWebappsAppManifestParser parser; QFileInfoList manifests = listManifests(manifestsDataPath); Q_FOREACH(QFileInfo manifest, manifests) { QVERIFY(manifest.isFile()); ManifestFileInfoOption result = parser.parse(manifest); QString filename = manifest.fileName(); QVERIFY(result.isvalid() == shouldManifestSucceed(filename)); } } void ManifestParserTest::testParseChromeOptions() { UnityWebappsAppManifestParser parser; QFileInfoList manifests = listManifests(manifestsDataPath); Q_FOREACH(QFileInfo manifest, manifests) { QVERIFY(manifest.isFile()); ManifestFileInfoOption result = parser.parse(manifest); QString filename = manifest.fileName(); QVERIFY(result.isvalid() == shouldManifestSucceed(filename)); verifyChrome(filename, result); } } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/main.cpp0000644000015301777760000000232412320722666025465 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include #include "tst_manifestParser.h" #include "tst_plugin.h" #include "tst_webappsAppModel.h" int runTests(int argc, char ** argv) { static QList tests; tests.append(new WebappsAppModelTest()); tests.append(new ManifestParserTest()); tests.append(new PluginTest()); Q_FOREACH(QObject *test, tests) { QTest::qExec(test, argc, argv); } return EXIT_SUCCESS; } int main (int argc, char ** argv) { return runTests(argc, argv); } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_plugin/tst_plugin.cpp0000644000015301777760000001152712320722666026736 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "tst_plugin.h" #include #include #include #include #include #include #include #include #include #include "plugin/unity-webapps-api.h" #include "plugin/abstract-item-model-adaptor.h" const QString webappName = "MyWebapp"; const QString url = "http://MyWebapp.com"; QVariantMap getParams() { QVariantMap params; params["domain"] = QVariant("MyWebapp.com"); params["name"] = QVariant("MyWebapp"); params["iconUrl"] = QVariant("icon://MyWebappcom"); return params; } PluginTest::PluginTest() :QObject(0) { } void PluginTest::initTestCase() {} void PluginTest::testLoadPlugin() { #if 0 QQmlEngine engine; QQmlComponent component(&engine); component.setData("import QtQuick 2.0\nimport Ubuntu.UnityWebApps 0.1\n" "Item { }", QUrl()); QObject *object = component.create(); QVERIFY(object != 0); delete object; #endif } void PluginTest::testInit() { #if 0 UnityWebapps * p = new UnityWebapps(); p->setHandleDesktopFileUpdates(false); p->init(webappName, url, getParams()); QVERIFY( ! p->getDesktopFileContent().isEmpty()); #endif } #include class TestAbstractListModel: public QAbstractListModel { Q_OBJECT Q_ENUMS(Roles) public: TestAbstractListModel(QObject * parent , const QStringList & data) : QAbstractListModel(parent) , _data(data) {} enum Roles { FirstRole = Qt::DisplayRole + 1, SecondRole, ThirdRole, FourthRole, }; QHash roleNames() const Q_DECL_OVERRIDE { QHash roles; roles[FirstRole] = QString("FirstRole").toLocal8Bit(); roles[SecondRole] = QString("SecondRole").toLocal8Bit(); roles[ThirdRole] = QString("ThirdRole").toLocal8Bit(); roles[FourthRole] = QString("FourthRole").toLocal8Bit(); return roles; } int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE { Q_UNUSED(parent); return _data.count(); } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE { int idx = index.row(); if (idx >= rowCount()) return QVariant(); QHash namePerRow = roleNames(); return QVariant(QString("%1-%2") .arg(QString(namePerRow[role])) .arg(_data.at(idx))); } private: QStringList _data; }; void PluginTest::testAbstractItemModelAdaptor() { QStringList data; data.append(QLatin1String("First")); data.append(QLatin1String("Second")); data.append(QLatin1String("Third")); data.append(QLatin1String("Fourth")); TestAbstractListModel * model = new TestAbstractListModel(0, data); AbstractItemModelAdaptor * adaptor = new AbstractItemModelAdaptor(); adaptor->setItemModel(model); QStringList roles = adaptor->roles(); QVERIFY(roles.count() == 4); for (int i = 0; i < model->rowCount(); ++i) { for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) { QString role = roles.at(roleIdx); QVariant item = adaptor->itemAt(i, role); QString expected = QString("%1-%2") .arg(role, data.at(i)); QVERIFY(item.isValid()); QVERIFY(item.canConvert(QMetaType::QString)); QVERIFY(0 == item.toString().compare(expected)); } } delete adaptor; delete model; } void PluginTest::testApplicationSignalHandler() { QProcess testApp; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("APP_ID", "application-api"); testApp.setProcessEnvironment(env); testApp.start("qmlscene -I ../../../src ../../../examples/api-bindings/application-api/main.qml"); testApp.waitForStarted(); testApp.terminate(); testApp.waitForFinished(); QVERIFY(true); } #include "tst_plugin.moc" unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_js/0000755000015301777760000000000012320723226023143 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_js/tst_sanitizer.qml0000644000015301777760000000553512320722666026577 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtTest 1.0 import "../../../src/Ubuntu/UnityWebApps/common/js/api-sanitizer.js" as SanitizerJs TestCase { name: "JavascriptApiCallSanitizerTests" function setup() { } function test_checkString() { setup(); var threw = false; threw = false; try { SanitizerJs.checkString(); } catch(e) { threw = true; }; compare(threw, true, "Null string type"); threw = false; try { SanitizerJs.checkString(1); } catch(e) { threw = true; }; compare(threw, true, "Invalid string type"); threw = false; try { SanitizerJs.checkString("blabla"); } catch(e) { threw = true; }; compare(threw, false, "Valid string"); threw = false; try { SanitizerJs.checkString(null, true); } catch(e) { threw = true; }; compare(threw, false, "Valid null string"); } function test_findName() { setup(); } function test_stringify() { setup(); compare(SanitizerJs.stringify(null), null, "Stringify null"); compare(SanitizerJs.stringify(undefined), undefined, "Stringify undefined"); compare(SanitizerJs.stringify("blabla"), "blabla", "Stringify string"); compare(SanitizerJs.stringify(1), 1, "Stringify number"); } function test_sanitizer() { setup(); var called = false; var actualArgs = null; var actualFuncName = null; var backend = { call: function(func_name, args) { called = true; actualArgs = args; actualFuncName = func_name; }, }; var sanitizer = null; called = false; sanitizer = SanitizerJs.createArgumentsSanitizer (backend, [], 'myfunc'); sanitizer(); compare(called, true, "Simple sanitizer func call") called = false; var args = [1, 2, "blabla"]; actualArgs = null; sanitizer = SanitizerJs.createArgumentsSanitizer (backend, [{ number: true }, { number: true }, { str: true }], 'myfunc'); sanitizer.apply(null, args); compare(called, true, "With args sanitizer func call"); expectFail(actualArgs == null, "Non null args"); compare(actualArgs.length, 3, "Invalid number of args received"); for (var i = 0; i < actualArgs.length; ++i) { compare(actualArgs[i], args[i], "Invalid arg value"); } compare(actualFuncName, "myfunc", "Invalid function name"); var threw = false; try { sanitizer.apply(null, []); } catch(e) { threw = true; } verify(threw, "Invalid call args count threw"); threw = false; try { sanitizer.apply(null, [1, 2, 3]); } catch(e) { threw = true; } verify(threw, "Invalid call args type threw"); } } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_js/test_js.cpp0000644000015301777760000000007512320722666025333 0ustar pbusernogroup00000000000000#include QUICK_TEST_MAIN(QmlTests) unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_js/test_js.pro0000644000015301777760000000077312320722666025356 0ustar pbusernogroup00000000000000include(../../../common-project-config.pri) TESTS += $$system(ls tst_*.qml) TEMPLATE = app TARGET = test_js QT += qml \ testlib \ qmltest CONFIG += no_keywords \ debug \ link_pkgconfig SOURCES += \ test_js.cpp OTHER_FILES += $$system(ls *.qml) \ $$system(ls *.js) \ $$system(ls *.sh) # make check target check.target = check check.commands = "set -e;" for(TEST, TESTS) { check.commands += ./runtest.sh $${TARGET} $${TEST} ../../../src; } QMAKE_EXTRA_TARGETS += check unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_js/runtest.sh0000755000015301777760000000262412320722666025221 0ustar pbusernogroup00000000000000#!/bin/bash # # Copyright © 2013 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Author: Juhapekka Piiroinen ################################################################################ _CMD="" _TARGET=$1 _TESTFILE=$2 _MAIN_MODULE_PATH=$3 _ARGS="-platform minimal" set +e function create_test_cmd { _CMD="./$_TARGET -input $_TESTFILE -import \"$_MAIN_MODULE_PATH\" -maxwarnings 20" } function execute_test_cmd { echo "Executing $_CMD $_ARGS" # segfault if [ $? -eq 139 ]; then return 2 fi # abort if [ $? -eq 134 ]; then return 2 fi return 0 } create_test_cmd execute_test_cmd if [ $? -eq 2 ]; then echo "FAILURE: Failed to execute test with -platform minimal, lets try without" _ARGS="" execute_test_cmd if [ $? -eq 2 ]; then echo "FAILURE: Failed to execute test." set -e exit -2 fi fi set -e unity-webapps-qml-0.1+14.04.20140408/tests/unit/unit.pro0000644000015301777760000000010612320722666023175 0ustar pbusernogroup00000000000000TEMPLATE=subdirs SUBDIRS = test_plugin \ test_qml \ test_js unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/0000755000015301777760000000000012320723226023320 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/tst_cleanup.qml0000644000015301777760000001037712320722666026373 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtTest 1.0 import Ubuntu.UnityWebApps 0.1 TestCase { name: "WebAppsDispatchCleanupTest" function setup() { } function createWebViewMock() { var messageReceivedCallbacks = []; var loadingChangedCallbacks = []; return { url: '', loadingChanged: { connect: function (callback) { loadingChangedCallbacks.push(callback); }, disconnect: function(callback) { loadingChangedCallbacks = loadingChangedCallbacks.filter(function (e) { return e !== callback; }); } }, experimental: { messageReceived: { connect: function (callback) { messageReceivedCallbacks.push(callback); }, disconnect: function(callback) { messageReceivedCallbacks = messageReceivedCallbacks.filter(function (e) { return e !== callback; }); } }, userScripts: [], postMessage: function(msg) {} }, callMessageReceivedCallbacks: function(msg) { var wrapped = {data: JSON.stringify(msg)}; messageReceivedCallbacks.forEach(function(f) { f(wrapped); }); } }; } function createWebAppsDispatcherWithSimpleBackend(mockedwebview) { var simple_backend = {This: { Is: { A: {Backend: function (args) { mockedWebView.called(args) } } } } }; var bindeeProxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(mockedwebview); return new UnityWebAppsJs.UnityWebApps(null, bindeeProxies, simple_backend, []); } function test_cleanupOnce() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "called"; var mwv = createWebViewMock(); var dispatcher = createWebAppsDispatcherWithSimpleBackend(mwv); mwv.callMessageReceivedCallbacks (UnityWebAppsUtils.formatUnityWebappsCall ('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 1, "This.Is.A.Backend backend called"); dispatcher.cleanup(); mwv.callMessageReceivedCallbacks (UnityWebAppsUtils.formatUnityWebappsCall ('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 1, "This.Is.A.Backend backend called"); } function test_multipleCleanup() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "called"; var mwv = createWebViewMock(); var dispatcher = createWebAppsDispatcherWithSimpleBackend(mwv); var dispatcher1 = createWebAppsDispatcherWithSimpleBackend(mwv); var dispatcher2 = createWebAppsDispatcherWithSimpleBackend(mwv); mwv.callMessageReceivedCallbacks (UnityWebAppsUtils.formatUnityWebappsCall ('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 3, "This.Is.A.Backend backend called"); dispatcher.cleanup(); mwv.callMessageReceivedCallbacks (UnityWebAppsUtils.formatUnityWebappsCall ('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 5, "This.Is.A.Backend backend called"); dispatcher1.cleanup(); mwv.callMessageReceivedCallbacks (UnityWebAppsUtils.formatUnityWebappsCall ('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 6, "This.Is.A.Backend backend called"); dispatcher2.cleanup(); mwv.callMessageReceivedCallbacks (UnityWebAppsUtils.formatUnityWebappsCall ('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 6, "This.Is.A.Backend backend called"); } SignalSpy { id: spy } // 'mocks' the 'bindee' Item { id: mockedWebView // back to webapps element signal loadingStarted() signal messageReceived(var message) // called signal called() signal injected(string src) signal loadingStartedConnected() signal messageReceivedConnected() } } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/test_qml.pro0000644000015301777760000000073312320722666025704 0ustar pbusernogroup00000000000000include(../../../common-project-config.pri) TESTS += $$system(ls tst_*.qml) TEMPLATE = app QT += qml \ quick \ qmltest CONFIG += no_keywords # build main test TARGET = test_qml SOURCES += \ test_qml.cpp OTHER_FILES += \ $$system(ls *.qml) \ $$system(ls *.sh) # make check target check.target = check check.commands = "set -e;" for(TEST, TESTS) { check.commands += ./runtest.sh $${TARGET} $${TEST} ../../../src; } QMAKE_EXTRA_TARGETS += check unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/tst_init.qml0000644000015301777760000000642612320722666025707 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtTest 1.0 import Ubuntu.UnityWebApps 0.1 TestCase { name: "WebAppsComponentInitTests" function setup() { webapps.__reset(); mockedWebView.disconnectAll(); } function test_nullInit() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "injected"; webapps.name = "test_nullInit"; webapps.__bind(webapps.bindee, []); compare(spy.count, 0, "Invalid (null) init call"); } function test_initAndInjected() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "injected"; webapps.name = "test_initAndInjected"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee, []); mockedWebView.loadingStarted(); compare(spy.count, 1, "Script has been injected"); } function test_initAndMessageHandlerAdded() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "loadingStartedConnected"; webapps.name = "test_initAndMessageHandlerAdded"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee, []); compare(spy.count, 1, "WebApp message connected on load started"); } function test_initWithNoName() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "messageReceivedConnected"; webapps.name = "test_initWithNoName"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee, []); compare(spy.count, 1, "WebApp message received connected"); } SignalSpy { id: spy } UnityWebApps { id: webapps name: "" bindee: null } // 'mocks' the 'bindee' Item { id: mockedWebView property var connectedSlots: [] function disconnectAll () { connectedSlots.forEach(function (slot) { slot.target.disconnect(slot.slot); }); connectedSlots = []; } function getUnityWebappsProxies() { return { injectUserScripts: function(userScriptUrls) { injected(userScriptUrls); }, sendToPage: function (message) { }, navigateTo: function (url) { }, loadingStartedConnect: function (onLoadingStarted) { mockedWebView.loadingStarted.connect(onLoadingStarted); loadingStartedConnected(); connectedSlots.push({'target': mockedWebView.loadingStarted, 'slot': onLoadingStarted}); }, messageReceivedConnect: function (onMessageReceived) { mockedWebView.messageReceived.connect(onMessageReceived); messageReceivedConnected(); connectedSlots.push({'target': mockedWebView.messageReceived, 'slot': onMessageReceived}); }, }; } // back to webapps element signal loadingStarted() signal messageReceived() // called signal injected(string src) signal loadingStartedConnected() signal messageReceivedConnected() } } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/tst_dispatch.qml0000644000015301777760000001300112320722666026526 0ustar pbusernogroup00000000000000import QtQuick 2.0 import QtTest 1.0 import Ubuntu.UnityWebApps 0.1 TestCase { name: "WebAppsDispatchTest" function setup() { webapps.__reset(); mockedWebView.disconnectAll(); } function test_properBackendDispatched() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "called"; var simple_backend = {This: { Is: { A: {Backend: function (args) { mockedWebView.called(args) } } } } }; webapps._opt_backendProxies = simple_backend; webapps.name = "test_properBackendDispatched"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee, []); mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 1, "This.Is.A.Backend backend called"); } function test_backendDispatchedWithProperArguments() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "called"; var params = [1, 2, 'AAU']; var action = function() { var args = arguments; mockedWebView.called(args); verify(null != args && args.length !== 0, "Non null args"); verify(typeof(args) == 'object', "Proper args type: " + typeof(args)); params.forEach(function (elt, idx) { compare(elt, args[idx], "Validate args index :" + idx); }); }; var simple_backend = {This: { Is: { A: {Backend: action } } } }; webapps._opt_backendProxies = simple_backend; webapps.name = "test_backendDispatchedWithProperArguments"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee); mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify(params))); compare(spy.count, 1, "This.Is.A.Backend backend called"); } function test_invalidBackendNotDispatched() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "called"; var invalid_backend = {This: { Is: { Not: { A: {Backend: function (args) { mockedWebView.called(args) } } } } } }; webapps._opt_backendProxies = invalid_backend; webapps.name = "test_invalidBackendNotDispatched"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee); mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"]))); compare(spy.count, 0, "This.Is.Not.A.Backend backend not called"); } function test_callbacksAreWrapped() { setup(); spy.clear(); spy.target = mockedWebView; spy.signalName = "called"; var action = function() { var args = Array.prototype.slice.call(arguments); mockedWebView.called(args); // make sure that we have a function that wraps the callbackid verify(null != args, "Non null args"); verify(typeof(args) == 'object', "Proper args type"); expectFail(args.some(function (arg) { return typeof(arg) == 'object' && 'callbackid' in arg; }), ""); verify(args.some(function (arg) { return typeof(arg) == 'function'; }), "We have at least a wrapping function"); }; var backend = {This: { Is: { A: {Backend: action } } } }; webapps._opt_backendProxies = backend; webapps.name = "test_callbacksAreWrapped"; webapps.bindee = mockedWebView; webapps.__bind(webapps.bindee); //We assume a bit about the implementation there ('callbackid') mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify([1, {'callbackid': 1}, "AAU"]))); compare(spy.count, 1, "This.Is.A.Backend backend called"); } SignalSpy { id: spy } UnityWebApps { id: webapps name: "" bindee: null } // 'mocks' the 'bindee' Item { id: mockedWebView property var connectedSlots: [] function disconnectAll () { connectedSlots.forEach(function (slot) { slot.target.disconnect(slot.slot); }); connectedSlots = []; } function getUnityWebappsProxies() { return { injectUserScripts: function(userScriptUrls) { injected(userScriptUrls); }, sendToPage: function (message) { }, navigateTo: function (url) { }, loadingStartedConnect: function (onLoadingStarted) { mockedWebView.loadingStarted.connect(onLoadingStarted); loadingStartedConnected(); connectedSlots.push({'target': mockedWebView.loadingStarted, 'slot': onLoadingStarted}); }, messageReceivedConnect: function (onMessageReceived) { mockedWebView.messageReceived.connect(onMessageReceived); messageReceivedConnected(); connectedSlots.push({'target': mockedWebView.messageReceived, 'slot': onMessageReceived}); }, }; } // back to webapps element signal loadingStarted() signal messageReceived(var message) // called signal called() signal injected(string src) signal loadingStartedConnected() signal messageReceivedConnected() } } unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/test_qml.cpp0000644000015301777760000000007512320722666025665 0ustar pbusernogroup00000000000000#include QUICK_TEST_MAIN(QmlTests) unity-webapps-qml-0.1+14.04.20140408/tests/unit/test_qml/runtest.sh0000755000015301777760000000262412320722666025376 0ustar pbusernogroup00000000000000#!/bin/bash # # Copyright © 2013 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Author: Juhapekka Piiroinen ################################################################################ _CMD="" _TARGET=$1 _TESTFILE=$2 _MAIN_MODULE_PATH=$3 _ARGS="-platform minimal" set +e function create_test_cmd { _CMD="./$_TARGET -input $_TESTFILE -import \"$_MAIN_MODULE_PATH\" -maxwarnings 20" } function execute_test_cmd { echo "Executing $_CMD $_ARGS" # segfault if [ $? -eq 139 ]; then return 2 fi # abort if [ $? -eq 134 ]; then return 2 fi return 0 } create_test_cmd execute_test_cmd if [ $? -eq 2 ]; then echo "FAILURE: Failed to execute test with -platform minimal, lets try without" _ARGS="" execute_test_cmd if [ $? -eq 2 ]; then echo "FAILURE: Failed to execute test." set -e exit -2 fi fi set -e unity-webapps-qml-0.1+14.04.20140408/tests/unit/main.cpp0000644000015301777760000000000112320722666023116 0ustar pbusernogroup00000000000000 unity-webapps-qml-0.1+14.04.20140408/webapps-qml.pro0000644000015301777760000000100012320722666022317 0ustar pbusernogroup00000000000000include(common-vars.pri) include(common-project-config.pri) include(docs/docs.pri ) TEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ src \ tests \ examples \ tools include(common-installs-config.pri) DISTNAME = $${PROJECT_NAME}-$${PROJECT_VERSION} EXCLUDES = \ --exclude-vcs \ --exclude-from .bzrignore --exclude=$${DISTNAME}.tar.bz2 dist.commands = "tar -cvjf $${DISTNAME}.tar.bz2 $$EXCLUDES --transform='s,^,$$DISTNAME/,' *" dist.depends = distclean QMAKE_EXTRA_TARGETS += dist unity-webapps-qml-0.1+14.04.20140408/common-installs-config.pri0000644000015301777760000000415412320722666024460 0ustar pbusernogroup00000000000000#----------------------------------------------------------------------------- # Common installation configuration for all projects. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # 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}'") } #----------------------------------------------------------------------------- # 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") } #----------------------------------------------------------------------------- # 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 OTHER_FILES += \ ../../src/Ubuntu/UnityWebApps/Settings.qml unity-webapps-qml-0.1+14.04.20140408/project-deployment.pri0000644000015301777760000000000012320722666023704 0ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/common-vars.pri0000644000015301777760000000145612320722666022341 0ustar pbusernogroup00000000000000#----------------------------------------------------------------------------- # 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 = webapps-qml-module #----------------------------------------------------------------------------- # Project version # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_VERSION = 0.1 API_URI = "Ubuntu.UnityWebApps" # End of File unity-webapps-qml-0.1+14.04.20140408/COPYING0000644000015301777760000010451312320722666020415 0ustar pbusernogroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . unity-webapps-qml-0.1+14.04.20140408/src/0000755000015301777760000000000012320723226020136 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/0000755000015301777760000000000012320723226021420 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/0000755000015301777760000000000012320723226024012 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/qmldir.in0000644000015301777760000000021112320722666025633 0ustar pbusernogroup00000000000000module $${API_URI} plugin $${TARGET} $${TARGET}Js 0.1 $${TARGET}.js $${TARGET}Utils 0.1 $${TARGET}Utils.js $${TARGET} 0.1 $${TARGET}.qml unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/UnityWebApps.pro0000644000015301777760000000300612320722666027134 0ustar pbusernogroup00000000000000include(../../../common-project-config.pri) include(../../../common-vars.pri) TEMPLATE = subdirs SUBDIRS += plugin # # # UNITY_API_JS_FILE = $$system($$PWD/../../../tools/inject-js-utils.py unity-webapps-api.js.in unity-webapps-api.js) inject_dependancies.target = unity-webapps-api.js inject_dependancies.depends = unity-webapps-api.js.in inject_dependancies.commands = $$PWD/../../../tools/inject-js-utils.py $< $@ QMAKE_EXTRA_TARGETS += inject_dependancies PRE_TARGETDEPS += \ unity-webapps-api.js # # deployment directives # PLUGIN_JS_FILES = \ $$system(ls *.js) \ $${UNITY_API_JS_FILE} CLIENT_JS_FILES = \ $$system(ls ./common/*/*.js) \ $$system(ls ./bindings/*/client/*.js) QML_FILES = $$system(ls *.qml) QMLDIR_FILE = qmldir QMAKE_SUBSTITUTES += qmldir.in OTHER_FILES += $$QML_FILES \ $$PLUGIN_JS_FILES \ $$CLIENT_JS_FILES \ $$system(ls ./bindings/*/backend/*.js) \ qmldir.in \ unity-webapps-api.js.in \ $${UNITY_API_JS_FILE} # # Installs # installPath = $$[QT_INSTALL_QML]/$$replace(API_URI, \\., /) qmldir_file.path = $$installPath qmldir_file.files = $$QMLDIR_FILE qml_files.path = $$installPath qml_files.files = $$QML_FILES js_files.path = $$installPath js_files.files = $$PLUGIN_JS_FILES runtime_api_binding_backend_js_files.path = $$installPath/bindings/runtime-api/backend/ runtime_api_binding_backend_js_files.files = ./bindings/runtime-api/backend/runtime-api.js INSTALLS += qmldir_file \ qml_files \ js_files \ runtime_api_binding_backend_js_files \ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js0000644000015301777760000002602512320722666027777 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ .pragma library var UBUNTU_WEBAPPS_BINDING_API_CALL_MESSAGE = "ubuntu-webapps-binding-call"; var UBUNTU_WEBAPPS_BINDING_OBJECT_METHOD_CALL_MESSAGE = "ubuntu-webapps-binding-call-object-method"; function QtWebviewAdapter(webview, disposer, makeSignalDisconnecter) { this.webview = webview; this.disposer = disposer; this.makeSignalDisconnecter = makeSignalDisconnecter; } QtWebviewAdapter.prototype = { injectUserScripts: function(userScriptUrls) { var scripts = this.webview.experimental.userScripts; for (var i = 0; i < userScriptUrls.length; ++i) { scripts.push(userScriptUrls[i]); } this.webview.experimental.userScripts = scripts; }, sendToPage: function (message) { this.webview.experimental.postMessage(message); }, loadingStartedConnect: function (onLoadingStarted) { function handler(loadRequest) { var LoadStartedStatus = 0; if (loadRequest.status === LoadStartedStatus) { onLoadingStarted(); } }; this.webview.loadingChanged.connect(handler); this.disposer.addDisposer(this.makeSignalDisconnecter(this.webview.loadingChanged, handler)); }, messageReceivedConnect: function (onMessageReceived) { function handler(raw) { onMessageReceived(JSON.parse(raw.data)); }; this.webview.experimental.messageReceived.connect(handler); this.disposer.addDisposer(this.makeSignalDisconnecter(this.webview.experimental.messageReceived, handler)); } } function OxideWebviewAdapter(webview, disposer, makeSignalDisconnecter) { this.webview = webview; this.disposer = disposer; this.makeSignalDisconnecter = makeSignalDisconnecter; this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://UnityWebappsApi"; } OxideWebviewAdapter.prototype = { injectUserScripts: function(userScriptUrls) { var context = this.webview.context; for (var i = 0; i < userScriptUrls.length; ++i) { var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:"; var scriptEnd = "}"; var statement = scriptStart + '"' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"' + '; matchAllFrames: false; url: "' + userScriptUrls[i] + '";' + scriptEnd; context.addUserScript(Qt.createQmlObject(statement, this.webview)); } }, sendToPage: function (message) { this.webview.rootFrame.sendMessageNoReply( this._WEBAPPS_USER_SCRIPT_CONTEXT, "UnityWebappApi-Host-Message", JSON.parse(message)); }, loadingStartedConnect: function (onLoadingStarted) { function handler(loadEvent) { var typeStarted = 0; //LoadEvent.TypeStarted if (loadEvent.type === typeStarted) { onLoadingStarted(); } } this.webview.loadingChanged.connect(handler); this.disposer.addDisposer(this.makeSignalDisconnecter(this.webview.loadingChanged, handler)); }, messageReceivedConnect: function (onMessageReceived) { function handler(msg, frame) { onMessageReceived(msg.args); } var script = 'import com.canonical.Oxide 1.0 as Oxide; ' + ' Oxide.ScriptMessageHandler { msgId: "UnityWebappApi-Message"; contexts: ["' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"]; ' + '}'; var messageHandler = Qt.createQmlObject(script, this.webview); messageHandler.callback = handler; this.webview.messageHandlers = [ messageHandler ]; } } function WebviewAdapterFactory(disposer, makeSignalDisconnecter) { this.disposer = disposer; this.makeSignalDisconnecter = makeSignalDisconnecter; }; WebviewAdapterFactory.prototype = { create: function(webview) { if (! webview) return null if (webview.experimental) { // assume qtwebkit return new QtWebviewAdapter(webview, this.disposer, this.makeSignalDisconnecter); } // assume oxide return new OxideWebviewAdapter(webview, this.disposer, this.makeSignalDisconnecter); } }; /** * Creates a simple proxy object that bridges * a UnityWebapps component with a given webview. * * The UnityWebApps component does not reach out directly to * a webview but expects something that provides a simple * interface of needed methods/functions. For the regular * case though (binding to an existing webview) writing the * interface manually is tedious, so this tool does it and creates * the bridging object to a webview. * * @param webViewId * @param handlers (optional) map of handlers for UnityWebApps * events to the external world, supported events: * { * onAppRaised: function () {} * } */ function makeProxiesForQtWebViewBindee(webViewId, eventHandlers) { var handlers = eventHandlers && typeof(eventHandlers) === 'object' ? eventHandlers : {}; function SignalConnectionDisposer() { this._signalConnectionDisposers = []; } SignalConnectionDisposer.prototype.disposeAndCleanupAll = function() { for(var i = 0; i < this._signalConnectionDisposers.length; ++i) { if (typeof(this._signalConnectionDisposers[i]) === 'function') { this._signalConnectionDisposers[i](); } } this._signalConnectionDisposers = []; }; SignalConnectionDisposer.prototype.addDisposer = function(d) { if ( ! this._signalConnectionDisposers.some(function(elt) { return elt === d; })) this._signalConnectionDisposers.push(d); }; return (function (disposer) { var makeSignalDisconnecter = function(sig, callback) { return function () { sig.disconnect(callback); }; }; var waf = new WebviewAdapterFactory(disposer, makeSignalDisconnecter); var proxy = waf.create(webViewId); // inject common function proxy.navigateTo = function(url) { webViewId.url = url; }; // called from the UnityWebApps side proxy.onAppRaised = function () { if (handlers && handlers.onAppRaised) handlers.onAppRaised(); }; // called from the UnityWebApps side proxy.cleanup = function() { disposer.disposeAndCleanupAll(); }; return proxy; })(new SignalConnectionDisposer()); } // Just to allow a smooth transition w/o breaking all the projects // remove qtwebkit name reference var makeProxiesForWebViewBindee = makeProxiesForQtWebViewBindee; /** * For a given list of objects returns a function that validates the presence and validity of the * specified properties. * * \param props list of object properties to validate. Each * property is an object w/ a 'name' and 'type' (as in typeof()). */ function isIterableObject(obj) { if (obj === undefined || obj === null) { return false; } var t = typeof(obj); var types = {'string': 0, 'function': 0, 'number': 0, 'undefined': 0, 'boolean': 0}; return types[t] === undefined; }; /** * Format a specific * * \param props list of object properties to validate. Each * property is an object w/ a 'name' and 'type' (as in typeof()). */ function formatUnityWebappsCall(type, serialized_args) { return {target: "unity-webapps-call", name: type, args: serialized_args}; } // // \brief For a given list of objects returns a function that validates the presence and validity of the // specified properties. // // \param props list of object properties to validate. Each property is an object w/ a 'name' and 'type' (as in typeof()). // function formatUnityWebappsCallbackCall(callbackid, args) { return {target: 'ubuntu-webapps-binding-callback-call', id: callbackid, args: args}; }; // // \brief For a given list of objects returns a function that validates the presence and validity of the // specified properties. // // \param props list of object properties to validate. Each property is an object w/ a 'name' and 'type' (as in typeof()). // function isUbuntuBindingCallbackCall(params) { function _has(o,k) { return (k in o) && o[k] != null; } return params != null && (typeof(params) === 'object') && _has(params,"target") && _has(params,"args") && _has(params,"id") && params.target === 'ubuntu-webapps-binding-callback-call'; }; /** * * */ function isUbuntuBindingObjectProxy(params) { function _has(o,k) { return (k in o) && o[k] != null; } return params != null && (typeof(params) === 'object') && _has(params,"type") && params.type === 'object-proxy' && _has(params,"apiid") && _has(params,"objecttype") && _has(params,"objectid"); }; // \brief For a given list of objects returns a function that validates the presence and validity of the // specified properties. // // \param props list of object properties to validate. Each property is an object w/ a 'name' and 'type' (as in typeof()). // function makePropertyValidator(props) { return function (object) { var _hasProperty = function(o, prop, type) { return o != null && (prop in o) && typeof (o[prop]) === type; }; return !props.some(function (prop) { return !_hasProperty(object, prop.name, prop.type); }); }; } // // \brief For a given list of objects returns a function that validates the presence and validity of the // specified properties. // var makeCallbackManager = function () { // TODO: remove magic name var prepend = 'ubuntu-webapps-api'; var callbacks = {}; return { store: function (callback) { if (!callback || !(callback instanceof Function)) throw "Invalid callback"; var __gensym = function() { return prepend + Math.random(); }; var id = __gensym(); while (undefined !== callbacks[id]) { id = __gensym(); } callbacks[id] = callback; return id; } , get: function (id) { return callbacks[id]; } }; }; // // // var toISODate = function(d) { function pad(n) { return n < 10 ? '0' + n : n; } return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + 'Z'; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/UnityWebApps.js0000644000015301777760000002063312320722666026755 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ .import "UnityWebAppsUtils.js" as UnityWebAppsUtils // // sendtoPageFunc: experimental.postMessage // // FIXME(AAU): lexical bindings (e.g. the global JSON object) do not seem to be // properly bounded when a qml file calls a js closure returned // and imported from an external js file. QML bug or developer bug? // var UnityWebApps = (function () { var json = JSON; /** * \param parentItem * \param bindeeProxies * \param backends * \param userscriptContent */ function _UnityWebApps(parentItem, bindeeProxies, backends, userscripts) { this._injected_unity_api_path = Qt.resolvedUrl('unity-webapps-api.js'); this._bindeeProxies = bindeeProxies; this._backends = backends; this._userscripts = userscripts || []; this._bind(); }; _UnityWebApps.prototype = { cleanup: function() { if (this._bindeeProxies.cleanup && typeof(this._bindeeProxies.cleanup) == 'function') this._bindeeProxies.cleanup(); }, proxies: function() { return this._bindeeProxies; }, /** * \internal * */ _bind: function () { var self = this; var cb = this._onMessageReceivedCallback.bind(self); self._bindeeProxies.messageReceivedConnect(cb); cb = this._onLoadingStartedCallback.bind(self); self._bindeeProxies.loadingStartedConnect(cb); }, /** * \internal * */ _onLoadingStartedCallback: function () { var scripts = [this._injected_unity_api_path]; for(var i = 0; i < this._userscripts.length; ++i) { scripts.push(Qt.resolvedUrl(this._userscripts[i])); } for (i = 0; i < scripts.length; ++i) console.debug('Injecting webapps script[' + i + '] : ' + scripts[i]); this._bindeeProxies.injectUserScripts(scripts); }, /** * \internal * */ _onMessageReceivedCallback: function (message) { if (!message) return; this._onMessage(message); }, /** * \internal * */ _onMessage: function(msg) { if ( ! this._isValidWebAppsMessage(msg)) { this._log ('Invalid message received: ' + json.stringify(msg)); return; } this._log ('WebApps API message received: ' + json.stringify(msg)); var self = this; var args = json.parse(msg.args); args = args.map (function (arg) { return self._wrapCallbackIds (arg); }); this._dispatch(msg, args); return true; }, /** * \internal * */ _dispatch: function(message, params) { var target = message.target; //TODO improve dispatch if (target === UnityWebAppsUtils.UBUNTU_WEBAPPS_BINDING_API_CALL_MESSAGE) { // Actuall call, e.g. 'Notification.showNotification("a","b") // being reduces to successive calls to associated objects: // Notification, showNotification // // TODO add proper error handling if (message.callback) { var cb = this._wrapCallbackIds (message.callback); params.push(cb); } this._dispatchApiCall (message.name, params); } else if (target === UnityWebAppsUtils.UBUNTU_WEBAPPS_BINDING_OBJECT_METHOD_CALL_MESSAGE) { var objectid = message.objectid; var api_uri = message.api_uri; var class_name = message.class_name; var method_name = message.name; var callback = this._wrapCallbackIds (message.callback); console.debug('Dispatching object method call to: ' + api_uri + ', method: ' + method_name); this._dispatchApiCall(api_uri + ".dispatchToObject", [{args: params, callback: callback, objectid: objectid, class_name: class_name, method_name: method_name}]); } }, /** * \internal * */ _dispatchApiCall: function (name, args) { var names = name.split('.'); var reducetarget = this._backends; try { // Assumes that we are calling a 'callable' from a succession of objects var t = names.reduce ( function (prev, cur) { return (typeof prev[cur] == "function") ? (function(prev, cur) { return prev[cur].bind(prev); })(prev, cur) : prev[cur]; }, reducetarget); t.apply (null, args); } catch (err) { this._log('Error while dispatching call to ' + names.join('.') + ': ' + err); } }, /** * \internal * */ _makeWebpageCallback: function (callbackid) { var self = this; return function () { // TODO add validation higher if (!self._bindeeProxies.sendToPage || !(self._bindeeProxies.sendToPage instanceof Function)) return; var callback_args = Array.prototype.slice.call(arguments); var message = UnityWebAppsUtils.formatUnityWebappsCallbackCall(callbackid, callback_args); self._bindeeProxies.sendToPage(JSON.stringify(message)); }; }, /** * \internal * * Wraps callback ids in proper callback that dispatch to the * webpage thru a proper event * */ _wrapCallbackIds: function (obj) { if ( ! obj) return obj; if ( ! UnityWebAppsUtils.isIterableObject(obj)) { return obj; } if (obj && obj.hasOwnProperty('callbackid') && obj.callbackid !== null) { return this._makeWebpageCallback (obj.callbackid); } var ret = (obj instanceof Array) ? [] : {}; for (var key in obj) { if (obj.hasOwnProperty(key)) { if (UnityWebAppsUtils.isIterableObject (obj[key])) { if (obj[key].callbackid != null) { ret[key] = this._makeWebpageCallback (obj[key].callbackid); } else { ret[key] = this._wrapCallbackIds (obj[key]); } } else { ret[key] = obj[key]; } } } return ret; }, /** * \internal * */ _log: function (msg) { try { console.debug(msg); } catch(e) {} }, /** * \internal * */ _isValidWebAppsMessage: function(message) { return message != null && message.target && message.target.indexOf('ubuntu-webapps-binding-call') === 0 && message.name && message.args; } }; return _UnityWebApps; }) (); unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/0000755000015301777760000000000012320723226025607 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/0000755000015301777760000000000012320723226030035 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/backend/0000755000015301777760000000000012320723226031424 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hu0000644000015301777760000002002412320722666033440 0ustar pbusernogroup00000000000000/** * * ContentHub API backend binding * */ function createContentHubApi(backendDelegate) { var PLUGIN_URI = 'Ubuntu.Content'; var VERSION = 0.1; var _contenthub = ContentHubBridge.ContentHub; function _nameToContentType(name) { var contentTypePerName = { "Pictures": ContentHubBridge.ContentType.Pictures, "Documents": ContentHubBridge.ContentType.Pictures, "Music": ContentHubBridge.ContentType.Pictures, }; return name in contentTypePerName ? contentTypePerName[name] : ContentHubBridge.ContentType.Unknown; }; function _contentTransferStateToName(state) { if (state === ContentHubBridge.ContentTransfer.Created) return "Created"; else if (state === ContentHubBridge.ContentTransfer.Initiated) return "Initiated"; else if (state === ContentHubBridge.ContentTransfer.InProgress) return "InProgress"; else if (state === ContentHubBridge.ContentTransfer.Charged) return "Charged"; else if (state === ContentHubBridge.ContentTransfer.Collected) return "Collected"; else if (state === ContentHubBridge.ContentTransfer.Aborted) return "Aborted"; else if (state === ContentHubBridge.ContentTransfer.Finalized) return "Finalized"; return "Created"; }; function ContentTransfer(transfer, objectid) { var id = objectid; if ( ! transfer) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentTransfer'); id = result.id; transfer = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(transfer, PLUGIN_URI, VERSION, 'ContentTransfer'); } this._id = id; this._object = transfer; this._callback = null; }; ContentTransfer.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, // object methods serialize: function() { return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentTransfer', objectid: this._id, } }, // properties selectionType: function(callback) { this._validate(); callback(this._object.selectionType) }, setSelectionType: function(selectionType) { this._validate(); this._object.selectionType = selectionType; }, items: function(callback) { this._validate(); // return in serialized form var items = []; for (var i = 0; i < this._object.items.length; ++i) { items.push({name: this._object.items[i].name, url: this._object.items[i].url}); } callback(items) }, // methods start: function(callback) { this._validate(); var self = this; this._callback = function () { callback(_contentTransferStateToName(self._object.state)); }; this._object.stateChanged.connect(this._callback); this._object.start(); }, finalize: function() { this._validate(); if (this._callback) this._object.stateChanged.disconnect(this._callback); this._callback = null; this._object.finalize(); }, }; function ContentStore(store, objectid) { var id = objectid; if ( ! store) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentStore'); id = result.id; store = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(store, PLUGIN_URI, VERSION, 'ContentStore'); } this._id = id; this._object = store; }; ContentStore.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, // object methods serialize: function() { return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentStore', objectid: this._id, } }, // properties uri: function(callback) { this._validate(); callback(this._object.uri); }, }; function ContentPeer(peer, objectid) { var id = objectid; if ( ! peer) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentPeer'); id = result.id; peer = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(peer, PLUGIN_URI, VERSION, 'ContentPeer'); } this._id = id; this._object = peer; }; ContentPeer.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentPeer', objectid: self._id, content: { appId: self._object.appId, name: self._object.name, }, } }, // properties appId: function(callback) { this._validate(); callback(this._object.appId); }, name: function(callback) { this._validate(); callback(this._object.name); }, }; function _constructorFromName(className) { var constructorPerName = { "ContentPeer": ContentPeer, "ContentStore": ContentStore, "ContentTransfer": ContentTransfer, }; return className in constructorPerName ? constructorPerName[className] : null; } return { defaultSourceForType: function(type, callback) { var source = new ContentPeer(_contenthub.defaultSourceForType(_nameToContentType(type))); callback(source.serialize()); }, defaultStoreForType: function(type, callback) { var store = new ContentStore(_contenthub.defaultStoreForType(_nameToContentType(type))); callback(store.serialize()); }, importContent: function(type, callback) { var transfer = new ContentTransfer(_contenthub.importContent(_nameToContentType(type))); callback(transfer.serialize()); }, importContentForPeer: function(type, peerProxy, callback) { if (! backendDelegate.isObjectProxyInfo(peerProxy)) { console.debug('importContentForPeer: invalid peer object proxy') callback(null); return; } var peer = backendDelegate.objectFromId(peerProxy.objectid); var transfer = new ContentTransfer(_contenthub.importContent(_nameToContentType(type), peer)); callback(transfer.serialize()); }, // Internal dispatchToObject: function(infos) { var args = infos.args; var callback = infos.callback; var method_name = infos.method_name; var objectid = infos.objectid; var class_name = infos.class_name; if (callback) args.push(callback); var o = backendDelegate.objectFromId(objectid); var Constructor = _constructorFromName(class_name); var instance = new Constructor(o, objectid); instance[method_name].apply(instance, args); } }; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/client/0000755000015301777760000000000012320723226031313 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/client/content-hub.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/client/content-hub0000644000015301777760000006601012320722666033476 0ustar pbusernogroup00000000000000/** * ContentHub is the entry point to resource io transfer from/to remote applications (peers). * @module ContentHub */ function createContentHubApi(backendBridge) { var PLUGIN_URI = 'ContentHub'; /** * ContentTransfer is an object created by the ContentHub to and allows one to properly setup and manage a data transfer between two peers. * @class ContentTransfer * @constructor * @example var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var pictureContentType = hub.ContentType.Pictures; hub.defaultSourceForType( pictureContentType , function(peer) { hub.importContentForPeer( pictureContentType, peer, function(transfer) { [setup the transfer options and store] transfer.start(function(state) { [...] }); }); }); */ function ContentTransfer(objectid, content) { this._proxy = backendBridge.createRemoteObject( PLUGIN_URI, 'ContentTransfer', objectid); this._store = content && content.store ? content.store : null; this._state = content && content.state ? content.state : null; this._selectionType = content && content.selectionType ? content.selectionType : null; this._direction = content && content.direction ? content.direction : null; }; ContentTransfer.prototype = { // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentTransfer', objectid: self._proxy.id(), } }, // properties /** * Retrieves the current store. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method store * @param callback (optional) {Function(String)} */ store: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('store', [], callback); return; } return this._store; }, /** * Sets the current store for the ContentTransfer. * * @method setStore * @param store {ContentStore} * @param callback (optional) {Function()} called when the store has been updated */ setStore: function(store, callback) { this._proxy.call('setStore', [store.serialize(), callback]); }, /** * Retrieves the current state. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method state * @param callback (optional) {Function(ContentTransfer.State)} */ state: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('state', [], callback); return; } return this._state; }, /** * Sets the state of the transfer. * * @method setState * @param state {ContentTransfer.State} * @param callback {Function()} called when the state has been updated */ setState: function(state, callback) { this._proxy.call('setState', [state, callback]); }, /** * Notifies the listener when the state of the transfer changes. * * @method onStateChanged * @param callback {Function(ContentTransfer.State)} */ onStateChanged: function(callback) { this._proxy.call('onStateChanged', [callback]); }, /** * Retrieves the current selection type. * * @method selectionType * @param callback {Function(ContentTransfer.SelectionType)} */ selectionType: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('selectionType', [], callback); return; } return this._selectionType; }, /** * Sets the selection type (single or multiple). * * @method setSelectionType * @param selectionType {ContentTransfer.SelectionType} * @param callback {Function()} called when the state has been updated */ setSelectionType: function(selectionType, callback) { this._selectionType = selectionType; this._proxy.call('setSelectionType', [selectionType, callback]); }, /** * Retrieves the current transfer direction. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method direction * @param callback (optional) {Function(ContentTransfer.Direction)} */ direction: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('direction', [], callback); return; } return this._direction; }, /** * Sets the transfer direction (import or export). * * @method setDirection * @param direction {ContentTransfer.Direction} * @param callback {Function()} called when the state has been updated */ setDirection: function(direction, callback) { this._direction = direction; this._proxy.call('setDirection', [direction, callback]); }, /** * Retrieves the list of items associated with the ContentTransfer. * * @method items * @param callback {Function( {Object{name: , url: }} )} */ items: function(callback) { this._proxy.call('items', [], callback); }, /** * Sets the list of items for the associated ContentTransfer (used when exporting). * * @method setItems * @param items {Array of Object{name: String, url: String}} * @param callback {Function()} called when the state has been updated */ setItems: function(items, callback) { this._proxy.call('setItems', [items, callback]); }, // methods /** * Starts a transfer * * @method start * @param callback {Function(ContentTransfer.State)} */ start: function(callback) { this._proxy.call('start', [callback]); }, /** * Sets State to ContentTransfer.Finalized and cleans up temporary files. * * @method finalize */ finalize: function() { this._proxy.call('finalize', []); }, // extras /** * Destroys the remote object. This proxy object is not valid anymore. * * @method destroy */ destroy: function() { this._proxy.call('destroy', []); }, }; /** * ContentPeer is an object returned by the ContentHub. It represents a remote peer that can be used in a request to export or import date. * @class ContentPeer * @module ContentHub * @constructor * @example var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var pictureContentType = hub.ContentType.Pictures; hub.defaultSourceForType( pictureContentType , function(peer) { [do something with the peer] }); */ function ContentPeer(objectid, content) { this._proxy = backendBridge.createRemoteObject( PLUGIN_URI, 'ContentPeer', objectid); this._appId = content && content.appId ? content.appId : null; this._name = content && content.name ? content.name : null; this._handler = content && content.handler ? content.handler : null; this._contentType = content && content.contentType ? content.contentType : null; this._selectionType = content && content.selectionType ? content.selectionType : null; this._isDefaultPeer = content && content.isDefaultPeer; }; ContentPeer.prototype = { // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentPeer', objectid: self._proxy.id(), } }, // properties /** * Retrieves the app Id of the associated peer. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method appId * @return {String} Application Id for this peer * @param callback (optional) {Function(String)} */ appId: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('appId', [], callback); return; } return this._appId; }, /** * Sets the app Id of the associated peer. * * @method setAppId * @param appId {String} * @param callback {Function()} called when the appId has been updated */ setAppId: function(appId, callback) { this._proxy.call('setAppId', [appId, callback]); }, /** * Retrieves the specific ContentHandler for this peer. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method handler * @return {String} ContentHandler for this peer * @param callback (optional) {Function(String)} */ handler: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('handler', [], callback); return; } return this._handler; }, /** * Sets specific ContentHandler for this peer. * * @method setHandler * @param handler {ContentHandler} * @param callback {Function()} called when the appId has been updated */ setHandler: function(handler, callback) { this._proxy.call('setHandler', [handler, callback]); }, /** * Retrieves the specific ContentType for this peer. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method contentType * @return {String} ContentType for this peer * @param callback (optional) {Function(String)} */ contentType: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('contentType', [], callback); return; } return this._contentType; }, /** * Sets specific ContentType for this peer. * * @method setContentType * @param contentType {ContentType} * @param callback {Function()} called when the content type has been updated */ setContentType: function(contentType, callback) { this._proxy.call('setContentType', [contentType, callback]); }, /** * Retrieves the specific SelectionType for this peer. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method selectionType * @return {String} ContentTransfer.SelectionType for this peer * @param callback (optional) {Function(String)} */ selectionType: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('selectionType', [], callback); return; } return this._selectionType; }, /** * Sets specific SelectionType for this peer. * * @method setSelectionType * @param selectionType {ContentTransfer.SelectionType} * @param callback {Function()} called when the content type has been updated */ setSelectionType: function(selectionType, callback) { this._proxy.call('setSelectionType', [selectionType, callback]); }, /** * Retrieves the name of the associated peer. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method name * @param callback (optional) {Function(String)} */ name: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('name', [], callback); return; } return this._name; }, /** * Returns true if the peer is a default one, false otherwise. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method isDefaultPeer * @param callback (optional) {Function(Bool)} */ isDefaultPeer: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('isDefaultPeer', [], callback); return; } return this._isDefaultPeer; }, // methods /** * Request to import data from this ContentPeer. * * @method request * @param callback {Function(ContentTransfer)} Called with the resulting content transfer */ request: function(callback) { this._proxy.call('request', [], callback); }, /** * Request to import data from this ContentPeer and use a ContentStore for permanent storage. * * @method requestForStore * @param store {ContentStore} Store used as a permanent storage * @param callback {Function(ContentTransfer)} Called with the resulting content transfer */ requestForStore: function(store, callback) { this._proxy.call('requestForStore', [store.serialize()], callback); }, // extras /** * Destroys the remote object. This proxy object is not valid anymore. * * @method destroy */ destroy: function() { this._proxy.call('destroy', []); }, }; /** * ContentStore is an object returned by the ContentHub. It represents a location where the resources imported or exported from a peer during a transfer operation are to be either saved or found. * @class ContentStore * @module ContentHub * @constructor * @example var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var pictureContentType = hub.ContentType.Pictures; hub.defaultStoreForType(pictureContentType, function(store) { [do something with the store] }); */ function ContentStore(objectid, content) { this._proxy = backendBridge.createRemoteObject( PLUGIN_URI, 'ContentStore', objectid); this._uri = content && content.uri ? content.uri : null; this._scope = content && content.scope ? content.scope : null; }; ContentStore.prototype = { // object methods serialize: function() { return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentStore', objectid: this._proxy.id(), } }, // properties //immutable /** * Retrieves the uri of the associated store. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method uri * @return {String} current uri * @param callback (optional) {Function(String)} */ uri: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('uri', [], callback); return; } return this._uri; }, /** * Retrieves the current scope. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method scope * @return {ContentScope} current scope * @param callback (optional) {Function(ContentScope)} */ scope: function(callback) { if (callback && typeof(callback) === 'function') { this._proxy.call('scope', [], callback); return; } return this._scope; }, /** * Sets the current scope. * * @method setScope * @param scope {ContentScope} * @param callback {Function()} called when the scope has been updated */ setScope: function(scope, callback) { this._proxy.call('setScope', [scope, callback]); }, // extras /** * Destroys the remote object. This proxy object is not valid anymore. * * @method destroy */ destroy: function() { this._proxy.call('destroy', []); }, }; function _constructorFromName(className) { var constructorPerName = { "ContentPeer": ContentPeer, "ContentStore": ContentStore, "ContentTransfer": ContentTransfer, }; return className in constructorPerName ? constructorPerName[className] : null; }; /** * The ContentHub object. * @class ContentHub * @static * @constructor */ return { /** ContentType is an enumeration of well known content types. Values: Pictures Documents Music Contacts @static @property ContentType {String} @example var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var pictureContentType = hub.ContentType.Pictures; */ ContentType: { All: "All", Unknown: "Unknown", Pictures: "Pictures", Documents: "Documents", Music: "Music", Contacts: "Contacts", }, /** ContentHandler is an enumeration of well known content handlers. Values: Source Destination Share @static @property ContentHandler {String} */ ContentHandler: { Source: "Source", Destination: "Destination", Share: "Share", }, /** ContentScope is an enumeration of well known scope types. Values: System User App @static @property ContentScope {String} */ ContentScope: { System: "System", User: "User", App: "App", }, ContentTransfer: { /** ContentTransfer.State is an enumeration of the state of a given ongoing ContentTransfer. Values: Created: Transfer created, waiting to be initiated. Initiated: Transfer has been initiated. InProgress: Transfer is in progress. Charged: Transfer is charged with items and ready to be collected. Collected: Items in the transfer have been collected. Aborted: Transfer has been aborted. Finalized: Transfer has been finished and cleaned up. @static @property ContentTransfer.State {String} @example var api = external.getUnityObject('1.0'); var hub = api.ContentHub; var transferState = hub.ContentTransfer.State; var pictureContentType = hub.ContentType.Pictures; hub.importContentForPeer( pictureContentType, peer, function(transfer) { hub.defaultStoreForType(pictureContentType, function(store) { transfer.setStore(store, function() { transfer.start(function(state) { if (transferState.Aborted === state) { [...] } [...] }); }); }); }); */ State: { // Transfer created, waiting to be initiated. Created: "Created", // Transfer has been initiated. Initiated: "Initiated", // Transfer is in progress. InProgress: "InProgress", // Transfer is charged with items and ready to be collected. Charged: "Charged", // Items in the transfer have been collected. Collected: "Collected", // Transfer has been aborted. Aborted: "Aborted", // Transfer has been finished and cleaned up. Finalized: "Finalized", }, /** ContentTransfer.Direction is an enumeration of the directions of a given ContentTransfer. Values: Import Export @static @property ContentTransfer.Direction {String} */ Direction: { // Transfer is a request to import content Import: "Import", // Transfer is a request to export content Export: "Export", }, /** ContentTransfer.SelectionType is an enumeration of the directions of a given ContentTransfer. Values: Single: Transfer should contain a single item Multiple: Transfer can contain multiple items @static @property ContentTransfer.SelectionType {String} */ SelectionType: { // Transfer should contain a single item Single: "Single", // Transfer can contain multiple items Multiple: "Multiple", }, }, /** * Creates a ContentPeer object for the given source type. * * @method getPeers * @param filters {Object} A dictionary of parameters to filter the result. The filtering keys are: * - contentType: desired ContentType * - handler: desired ContentHandler * * @param callback {Function(List of ContentPeer objects)} Callback that receives the result or null */ getPeers: function(filter, callback) { backendBridge.call('ContentHub.getPeers', [filter], callback); }, /** * Creates a ContentStore object for the given scope type. * * @method getStore * @param scope {ContentScope} The content scope for the store * @param callback {Function(ContentStore)} Callback that receives the result or null */ getStore: function(scope, callback) { backendBridge.call('ContentHub.getStore', [scope], callback); }, /** * Launches the content peer picker ui that allows the user to select a peer. * * @method launchContentPeerPicker * @param filters {Object} A dictionary of parameters to filter the result. The filtering keys are: * - contentType: desired ContentType * - handler: desired ContentHandler * - showTitle: boolean value indicating if the title should be visible * @param onPeerSelected {Function(ContentPeer)} Called when the user has selected a peer * @param onCancelPressed {Function()} Called when the user has pressed cancel */ launchContentPeerPicker: function(filters, onPeerSelected, onCancelPressed) { backendBridge.call('ContentHub.launchContentPeerPicker', [filters, onPeerSelected, onCancelPressed]); }, /** * Sets a handler that is to be called when the current application is the * target of an export request. * * @method onExportRequested * @param callback {Function(ContentTransfer)} Function when one requests a resource to be exported. * The corresponding ContentTransfer is provided as a parameter. * * @example var api = external.getUnityObject(1.0); var hub = api.ContentHub; var transferState = hub.ContentTransfer.State; function _exportRequested(transfer) { var url = window.location.href; url = url.substr(0, url.lastIndexOf('/')+1) + 'img/ubuntuone-music.png'; transfer.setItems([{name: 'Ubuntu One', url: url}], function() { transfer.setState(hub.ContentTransfer.State.Charged); }); }; hub.onExportRequested(_exportRequested); */ onExportRequested: function(callback) { backendBridge.call('ContentHub.onExportRequested', [callback]); }, api: { /** * Creates a ContentStore object for the given ContentPeer. * * @method api.importContent * @param type {ContentType} type of the content to import * @param peer {ContentPeer} peer whos content should be imported * @param transferOptions {Object} a dictionary of transfer options. The options are the following: * - multipleFiles {Bool}: specified if a transfer should involve multiple files or not * - scope {ContentScope}: specifies the location where the transferred files should be copied to * @param onError {Function(reason:)} called when the transfer has failed * @param onSuccess {Function(Array of {ContentItem})} called when the transfer has been a success and items are available */ importContent: function(type, peer, transferOptions, onSuccess, onError) { backendBridge.call('ContentHub.apiImportContent', [type, peer.serialize(), transferOptions, onSuccess, onError]); } }, // Internal /** * @private * */ createObjectWrapper: function(objectType, objectId, content) { var Constructor = _constructorFromName(objectType); return new Constructor(objectId, content); }, }; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/client/yuidoc.json0000644000015301777760000000034712320722666033515 0ustar pbusernogroup00000000000000{ "name": "Content Hub JS API", "description": "Ubuntu App Platform Content Hub JavaScript API docs", "version": "0.1", "options": { "outdir": "./docsbuild", "themedir": "../../yuidoc-theme" } } ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/client/index.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/content-hub/client/index.handl0000644000015301777760000000007312320722666033441 0ustar pbusernogroup00000000000000

Welcome to Ubuntu Content Hub JavaScript API Docs

unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/0000755000015301777760000000000012320723226030710 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/0000755000015301777760000000000012320723226032277 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016100000000000011213 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online0000644000015301777760000000552012320722666033517 0ustar pbusernogroup00000000000000function createOnlineAccountsApi(backendDelegate) { var PLUGIN_URI = 'Ubuntu.OnlineAccounts'; var VERSION = 0.1; function Manager() { this._object = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'Manager'); }; Manager.prototype = { _validate: function() { if (! object) throw new TypeError("Invalid object null"); }, // methods createAccount: function(providerName) { this._validate(); return this._object.createAccount(providerName); }, loadAccount: function(id) { this._validate(); return this._object.loadAccount(id); }, }; function ProviderModel() { this._object = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ProviderModel'); }; ProviderModel.prototype = { _validate: function() { if (! object) throw new TypeError("Invalid object null"); }, // QAbtractListModel prototype at: function(idx, callback) { if (idx >= this.proxy.count || ! this._modelAdaptor) { return null; } var result = {}; for (var role in this._roles) { result[role] = this._modelAdaptor.itemAt(idx, role); } callback(result); } }; function AccountServiceModel() { this._object = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'AccountServiceModel'); }; AccountServiceModel.prototype = { _validate: function() { if (! object) throw new TypeError("Invalid object null"); }, // properties count: function() { this.validate(); return this._object.count; }, service: function() { this.validate(); return this._object.service; }, setService: function(service) { this.validate(); this._object.service = service; }, provider: function() { this.validate(); return this._object.provider; }, setProvider: function(provider) { this.validate(); this._object.provider = provider; }, serviceType: function() { this.validate(); return this._object.serviceType; }, setServiceType: function(serviceType) { this.validate(); this._object.serviceType = serviceType; }, accountId: function() { this.validate(); return this._object.accountId; }, setAccountId: function(accountId) { this.validate(); this._object.accountId = accountId; }, // QAbtractListModel prototype forEach: function(callback) { return this.proxy.call('QAbtractListModel::forEach', callback); }, at: function(idx, callback) { return this.proxy.call('QAbtractListModel::at', callback); } }; return { createAccountServiceModel: function() { return new AccountServiceModel(); }, createManager: function() { return new Manager(); }, createProviderModel: function() { return new ProviderModel(); }, }; } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/0000755000015301777760000000000012320723226032166 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/yuidoc.jsonunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/yuidoc.0000644000015301777760000000035712320722666033477 0ustar pbusernogroup00000000000000{ "name": "Online Accounts JS API", "description": "Ubuntu App Platform Online Accounts JavaScript API docs", "version": "0.1", "options": { "outdir": "./docsbuild", "themedir": "../../yuidoc-theme" } } ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/index.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/index.h0000644000015301777760000000007712320722666033461 0ustar pbusernogroup00000000000000

Welcome to Ubuntu Online Accounts JavaScript API Docs

././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/online-accounts.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/online-accounts/client/online-0000644000015301777760000001606312320722666033467 0ustar pbusernogroup00000000000000/** * OnlineAccounts is the entry point to online accounts service access. * @module OnlineAccounts */ function createOnlineAccountsApi(backendBridge) { var PLUGIN_URI = 'OnlineAccounts'; /** * AccountService represents an instance of a service in an Online Accounts. * * The AcountService object is not directly constructible but returned as a result of * OnlineAccounts api calls. * * @class AccountService */ function AccountService(id, content) { this._proxy = backendBridge.createRemoteObject( PLUGIN_URI, 'AccountService', id); this._accountId = content && content.accountId ? content.accountId : null; this._enabled = content && content.enabled ? content.enabled : null; this._serviceEnabled = content && content.serviceEnabled ? content.serviceEnabled : null; this._displayName = content && content.displayName ? content.displayName : null; this._provider = content && content.provider ? content.provider : null; this._service = content && content.service ? content.service : null; }; AccountService.prototype = { // properties /** * Returns the account's numeric ID; note that all * AccountService objects which work on the same online account will have the same ID. * * @method accountId * @return {String} Value for the accountId */ accountId: function() { return this._accountId; }, /** * This read-only property returns whether the AccountService is enabled. * An application shouldn't use an AccountService which is disabled * * @method enabled * @return {Boolean} Value for the enabled flag */ enabled: function() { return this._enabled; }, /** * Returns The account's display name (usually the user's login or ID). * Note that all AccountService objects which work on the same online account * will share the same display name. * * @method displayName * @return {String} Value of the displayName */ displayName: function() { return this._displayName; }, /** * Returns an object representing the provider which provides the account. * * The returned object will have at least these properties: * - 'id' is the unique identifier for this provider * - 'displayName' * - 'iconName' * * @method provider * @return {Object} Value object for the provider */ provider: function() { return this._provider; }, /** * Returns an object representing the service which this AccountService instantiates * * The returned object will have at least these properties: * - 'id' is the unique identifier for this service * - 'displayName' * - 'iconName' * - 'serviceTypeId' identifies the provided service type * * @method service * @return {Object} Value object for the service */ service: function() { return this._service; }, // methods /** * Perform the authentication on this account. * * The callback will be called with the authentication result object which will have * these properties: * - 'error': error message if the authentication was a failure * - 'authenticated': boolean value that identifies if the operation was a success * - 'data': Object with the data returned by the authentication process. An 'AccessToken' property can be usually found (when it applies) with the OAuth access token. * * If the callback parameter is not set, the current "local" value is retrieved. * * @method authenticate * @param callback {Function(Object)} */ authenticate: function(callback) { this._proxy.call('authenticate', [callback]); }, // extras /** * Destroys the remote object. This proxy object is not valid anymore. * * @method destroy */ destroy: function() { this._proxy.call('destroy', []); }, }; function _constructorFromName(className) { var constructorPerName = { "AccountService": AccountService, }; return className in constructorPerName ? constructorPerName[className] : null; }; /** * The OnlineAccounts object is the entry point to online accounts service access. * @class OnlineAccounts * * @example var api = external.getUnityObject(1.0); var oa = api.OnlineAccounts; oa.api.getAccounts({'provider': 'facebook'}, function(result) { [...] }); */ return { api: { /** * Gets the configured accounts satisfying the given filters. * * @method api.getAccounts * @param filters {Object} A dictionary of parameters to filter the result. The filtering keys are: * - application: the ID of a application (see /usr/share/accounts/applications/ or ~/.local/share/accounts/applications/ for a list of the available applications) * - provider: the ID of a provider (see /usr/share/accounts/providers/ or ~/.local/share/accounts/providers/ for a list of the available providers) * - service: the ID of a service (see /usr/share/accounts/services/ or ~/.local/share/accounts/services/ for a list of the available services) * * @param callback {Function(List of AccountService objects)} Callback that receives the result or null * * @example var api = external.getUnityObject(1.0); var oa = api.OnlineAccounts; oa.api.getAccounts({'provider': 'facebook'}, function(result) { for (var i = 0; i < result.length; ++i) { console.log("name: " + result[i].displayName() + ', id: ' + result[i].accountId() + ', providerName: ' + result[i].provider().displayName + ', enabled: ' + (result[i].enabled() ? "true" : "false") ); } }); */ getAccounts: function(filters, callback) { backendBridge.call('OnlineAccounts.getAccounts' , [filters] , callback); }, }, // Internal /** * @private * */ createObjectWrapper: function(objectType, objectId, content) { var Constructor = _constructorFromName(objectType); return new Constructor(objectId, content); }, }; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/0000755000015301777760000000000012320723226030203 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/layouts/0000755000015301777760000000000012320723226031703 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/layouts/main.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/layouts/main.hand0000644000015301777760000000227612320722666033501 0ustar pbusernogroup00000000000000 {{htmlTitle}}
API Docs for: {{projectVersion}}
{{>layout_content}}
unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/0000755000015301777760000000000012320723226031505 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/js/0000755000015301777760000000000012320723226032121 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/js/yui-prettify.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/js/yui-pre0000644000015301777760000000377512320722666033461 0ustar pbusernogroup00000000000000/* * Copyright 2011 Yahoo! Inc. * All rights reserved. *- * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Yahoo! Inc. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. *- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ YUI().use('node', function(Y) { var code = Y.all('.prettyprint.linenums'); if (code.size()) { code.each(function(c) { var lis = c.all('ol li'), l = 1; lis.each(function(n) { n.prepend(''); l++; }); }); var h = location.hash; location.hash = ''; h = h.replace('LINE_', 'LINENUM_'); location.hash = h; } }); unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/js/tabs.js0000644000015301777760000000537412320722666033430 0ustar pbusernogroup00000000000000/* * Copyright 2011 Yahoo! Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Yahoo! Inc. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ YUI({ insertBefore: 'site_styles' }).use('tabview', function(Y) { var classdocs = Y.one('#classdocs'), tabviewIndexTable = {}; if (classdocs) { if (classdocs.all('li').size()) { var tabview = new Y.TabView({ srcNode: classdocs }); tabview.render(); classdocs.all('li a').each(function (item, index) { var hash = item.get(['hash']); type = hash.substring(1); if (!tabviewIndexTable[type]) { tabviewIndexTable[type] = index; } }) Y.all('.sidebox.on-page').each(function (item, index) { var children = item.all('li a'); children.each(function (cItem, cIndex) { return function () { var handleClick = function (e) { var node = Y.one(this), hash = node.get(['hash']), hashValue = hash.substring(1).split('_'), type = hashValue.shift(), ogKey = hashValue.join('_'); // in case the hash had other underscores if (tabviewIndexTable[type] > -1 && tabviewIndexTable[type] !== currentTab) { currentTab = tabviewIndexTable[type]; tabview.selectChild(tabviewIndexTable[type]); } } Y.on('click', handleClick, cItem) }() }) }); } } }); unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/0000755000015301777760000000000012320723226033002 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/prettify/unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/pre0000755000015301777760000000000012320723226033511 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017200000000000011215 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/prettify/prettify-min.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/pre0000644000015301777760000004564712320722666033542 0ustar pbusernogroup00000000000000/* * Copyright 2011 Yahoo! Inc. * All rights reserved. *- * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Yahoo! Inc. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. *- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ window.PR_SHOULD_USE_CONTINUATION=true;var prettyPrintOne;var prettyPrint;(function(){var O=window;var j=["break,continue,do,else,for,if,return,while"];var v=[j,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var q=[v,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var m=[q,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var y=[q,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var T=[y,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"];var s="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes";var x=[q,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var t="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var J=[j,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var g=[j,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var I=[j,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var B=[m,T,x,t+J,g,I];var f=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;var D="str";var A="kwd";var k="com";var Q="typ";var H="lit";var M="pun";var G="pln";var n="tag";var F="dec";var K="src";var R="atn";var o="atv";var P="nocode";var N="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function l(ab){var af=0;var U=false;var ae=false;for(var X=0,W=ab.length;X122)){if(!(am<65||ai>90)){ah.push([Math.max(65,ai)|32,Math.min(am,90)|32])}if(!(am<97||ai>122)){ah.push([Math.max(97,ai)&~32,Math.min(am,122)&~32])}}}}ah.sort(function(aw,av){return(aw[0]-av[0])||(av[1]-aw[1])});var ak=[];var aq=[];for(var at=0;atau[0]){if(au[1]+1>au[0]){ao.push("-")}ao.push(V(au[1]))}}ao.push("]");return ao.join("")}function Y(an){var al=an.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var aj=al.length;var ap=[];for(var am=0,ao=0;am=2&&ak==="["){al[am]=Z(ai)}else{if(ak!=="\\"){al[am]=ai.replace(/[a-zA-Z]/g,function(aq){var ar=aq.charCodeAt(0);return"["+String.fromCharCode(ar&~32,ar|32)+"]"})}}}}return al.join("")}var ac=[];for(var X=0,W=ab.length;X=0;){U[ae.charAt(ag)]=aa}}var ah=aa[1];var ac=""+ah;if(!ai.hasOwnProperty(ac)){aj.push(ah);ai[ac]=null}}aj.push(/[\0-\uffff]/);X=l(aj)})();var Z=V.length;var Y=function(aj){var ab=aj.sourceCode,aa=aj.basePos;var af=[aa,G];var ah=0;var ap=ab.match(X)||[];var al={};for(var ag=0,at=ap.length;ag=5&&"lang-"===ar.substring(0,5);if(ao&&!(ak&&typeof ak[1]==="string")){ao=false;ar=K}if(!ao){al[ai]=ar}}var ad=ah;ah+=ai.length;if(!ao){af.push(aa+ad,ar)}else{var an=ak[1];var am=ai.indexOf(an);var ae=am+an.length;if(ak[2]){ae=ai.length-ak[2].length;am=ae-an.length}var au=ar.substring(5);C(aa+ad,ai.substring(0,am),Y,af);C(aa+ad+am,an,r(au,an),af);C(aa+ad+ae,ai.substring(ae),Y,af)}}aj.decorations=af};return Y}function i(V){var Y=[],U=[];if(V.tripleQuotedStrings){Y.push([D,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(V.multiLineStrings){Y.push([D,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{Y.push([D,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(V.verbatimStrings){U.push([D,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var ab=V.hashComments;if(ab){if(V.cStyleComments){if(ab>1){Y.push([k,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{Y.push([k,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}U.push([D,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])}else{Y.push([k,/^#[^\r\n]*/,null,"#"])}}if(V.cStyleComments){U.push([k,/^\/\/[^\r\n]*/,null]);U.push([k,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(V.regexLiterals){var aa=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");U.push(["lang-regex",new RegExp("^"+N+"("+aa+")")])}var X=V.types;if(X){U.push([Q,X])}var W=(""+V.keywords).replace(/^ | $/g,"");if(W.length){U.push([A,new RegExp("^(?:"+W.replace(/[\s,]+/g,"|")+")\\b"),null])}Y.push([G,/^\s+/,null," \r\n\t\xA0"]);var Z=/^.[^\s\w\.$@\'\"\`\/\\]*/;U.push([H,/^@[a-z_$][a-z_$@0-9]*/i,null],[Q,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[G,/^[a-z_$][a-z_$@0-9]*/i,null],[H,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[G,/^\\[\s\S]?/,null],[M,Z,null]);return h(Y,U)}var L=i({keywords:B,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function S(W,ah,aa){var V=/(?:^|\s)nocode(?:\s|$)/;var ac=/\r\n?|\n/;var ad=W.ownerDocument;var ag=ad.createElement("li");while(W.firstChild){ag.appendChild(W.firstChild)}var X=[ag];function af(am){switch(am.nodeType){case 1:if(V.test(am.className)){break}if("br"===am.nodeName){ae(am);if(am.parentNode){am.parentNode.removeChild(am)}}else{for(var ao=am.firstChild;ao;ao=ao.nextSibling){af(ao)}}break;case 3:case 4:if(aa){var an=am.nodeValue;var ak=an.match(ac);if(ak){var aj=an.substring(0,ak.index);am.nodeValue=aj;var ai=an.substring(ak.index+ak[0].length);if(ai){var al=am.parentNode;al.insertBefore(ad.createTextNode(ai),am.nextSibling)}ae(am);if(!aj){am.parentNode.removeChild(am)}}}break}}function ae(al){while(!al.nextSibling){al=al.parentNode;if(!al){return}}function aj(am,at){var ar=at?am.cloneNode(false):am;var ap=am.parentNode;if(ap){var aq=aj(ap,1);var ao=am.nextSibling;aq.appendChild(ar);for(var an=ao;an;an=ao){ao=an.nextSibling;aq.appendChild(an)}}return ar}var ai=aj(al.nextSibling,0);for(var ak;(ak=ai.parentNode)&&ak.nodeType===1;){ai=ak}X.push(ai)}for(var Z=0;Z=U){aj+=2}if(Y>=ar){ac+=2}}}finally{if(au){au.style.display=ak}}}var u={};function d(W,X){for(var U=X.length;--U>=0;){var V=X[U];if(!u.hasOwnProperty(V)){u[V]=W}else{if(O.console){console.warn("cannot override language handler %s",V)}}}}function r(V,U){if(!(V&&u.hasOwnProperty(V))){V=/^\s*]*(?:>|$)/],[k,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[M,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);d(h([[G,/^[\s]+/,null," \t\r\n"],[o,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[n,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[R,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[M,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);d(h([],[[o,/^[\s\S]+/]]),["uq.val"]);d(i({keywords:m,hashComments:true,cStyleComments:true,types:f}),["c","cc","cpp","cxx","cyc","m"]);d(i({keywords:"null,true,false"}),["json"]);d(i({keywords:T,hashComments:true,cStyleComments:true,verbatimStrings:true,types:f}),["cs"]);d(i({keywords:y,cStyleComments:true}),["java"]);d(i({keywords:I,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);d(i({keywords:J,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);d(i({keywords:t,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);d(i({keywords:g,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);d(i({keywords:x,cStyleComments:true,regexLiterals:true}),["js"]);d(i({keywords:s,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);d(h([],[[D,/^[\s\S]+/]]),["regex"]);function e(X){var W=X.langExtension;try{var U=b(X.sourceNode,X.pre);var V=U.sourceCode;X.sourceCode=V;X.spans=U.spans;X.basePos=0;r(W,V)(X);E(X)}catch(Y){if(O.console){console.log(Y&&Y.stack?Y.stack:Y)}}}function z(Y,X,W){var U=document.createElement("pre");U.innerHTML=Y;if(W){S(U,W,true)}var V={langExtension:X,numberLines:W,sourceNode:U,pre:1};e(V);return U.innerHTML}function c(aj){function ab(al){return document.getElementsByTagName(al)}var ah=[ab("pre"),ab("code"),ab("xmp")];var V=[];for(var ae=0;ae]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); ././@LongLink0000000000000000000000000000016700000000000011221 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/prettify/CHANGES.htmlunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/pre0000644000015301777760000001370412320722666033527 0ustar pbusernogroup00000000000000 Change Log README

Known Issues

  • Perl formatting is really crappy. Partly because the author is lazy and partly because Perl is hard to parse.
  • On some browsers, <code> elements with newlines in the text which use CSS to specify white-space:pre will have the newlines improperly stripped if the element is not attached to the document at the time the stripping is done. Also, on IE 6, all newlines will be stripped from <code> elements because of the way IE6 produces innerHTML. Workaround: use <pre> for code with newlines.

Change Log

29 March 2007

  • Added tests for PHP support to address issue 3.
  • Fixed bug: prettyPrintOne was not halting. This was not reachable through the normal entry point.
  • Fixed bug: recursing into a script block or PHP tag that was not properly closed would not silently drop the content. (test)
  • Fixed bug: was eating tabs (test)
  • Fixed entity handling so that the caveat

    Caveats: please properly escape less-thans. x&lt;y instead of x<y, and use " instead of &quot; for string delimiters.

    is no longer applicable.
  • Added noisefree's C# patch
  • Added a distribution that has comments and whitespace removed to reduce download size from 45.5kB to 12.8kB.

4 Jul 2008

  • Added language specific formatters that are triggered by the presence of a lang-<language-file-extension>
  • Fixed bug: python handling of '''string'''
  • Fixed bug: / in regex [charsets] should not end regex

5 Jul 2008

  • Defined language extensions for Lisp and Lua

14 Jul 2008

  • Language handlers for F#, OCAML, SQL
  • Support for nocode spans to allow embedding of line numbers and code annotations which should not be styled or otherwise affect the tokenization of prettified code. See the issue 22 testcase.

6 Jan 2009

  • Language handlers for Visual Basic, Haskell, CSS, and WikiText
  • Added .mxml extension to the markup style handler for Flex MXML files. See issue 37.
  • Added .m extension to the C style handler so that Objective C source files properly highlight. See issue 58.
  • Changed HTML lexer to use the same embedded source mechanism as the wiki language handler, and changed to use the registered CSS handler for STYLE element content.

21 May 2009

  • Rewrote to improve performance on large files. See benchmarks.
  • Fixed bugs with highlighting of Haskell line comments, Lisp number literals, Lua strings, C preprocessor directives, newlines in Wiki code on Windows, and newlines in IE6.

14 August 2009

  • Fixed prettifying of <code> blocks with embedded newlines.

3 October 2009

  • Fixed prettifying of XML/HTML tags that contain uppercase letters.

19 July 2010

  • Added support for line numbers. Bug 22
  • Added YAML support. Bug 123
  • Added VHDL support courtesy Le Poussin.
  • IE performance improvements. Bug 102 courtesy jacobly.
  • A variety of markup formatting fixes courtesy smain and thezbyg.
  • Fixed copy and paste in IE[678].
  • Changed output to use &#160; instead of &nbsp; so that the output works when embedded in XML. Bug 108.
././@LongLink0000000000000000000000000000017300000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/prettify/prettify-min.cssunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/pre0000644000015301777760000000124312320722666033522 0ustar pbusernogroup00000000000000.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/prettify/COPYINGunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/pre0000644000015301777760000002613612320722666033532 0ustar pbusernogroup00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/prettify/README.htmlunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/vendor/pre0000644000015301777760000001735012320722666033530 0ustar pbusernogroup00000000000000 Javascript code prettifier Languages : CH

Javascript code prettifier

Setup

  1. Download a distribution
  2. Include the script and stylesheets in your document (you will need to make sure the css and js file are on your server, and adjust the paths in the script and link tag)
    <link href="prettify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="prettify.js"></script>
  3. Add onload="prettyPrint()" to your document's body tag.
  4. Modify the stylesheet to get the coloring you prefer

Usage

Put code snippets in <pre class="prettyprint">...</pre> or <code class="prettyprint">...</code> and it will automatically be pretty printed.
The original Prettier
class Voila {
public:
  // Voila
  static const string VOILA = "Voila";

  // will not interfere with embedded tags.
}
class Voila {
public:
  // Voila
  static const string VOILA = "Voila";

  // will not interfere with embedded tags.
}

FAQ

Which languages does it work for?

The comments in prettify.js are authoritative but the lexer should work on a number of languages including C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl and Ruby, but, because of commenting conventions, doesn't work on Smalltalk, or CAML-like languages.

LISPy languages are supported via an extension: lang-lisp.js.

And similarly for CSS, Haskell, Lua, OCAML, SML, F#, Visual Basic, SQL, Protocol Buffers, and WikiText..

If you'd like to add an extension for your favorite language, please look at src/lang-lisp.js and file an issue including your language extension, and a testcase.

How do I specify which language my code is in?

You don't need to specify the language since prettyprint() will guess. You can specify a language by specifying the language extension along with the prettyprint class like so:

<pre class="prettyprint lang-html">
  The lang-* class specifies the language file extensions.
  File extensions supported by default include
    "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
    "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
    "xhtml", "xml", "xsl".
</pre>

It doesn't work on <obfuscated code sample>?

Yes. Prettifying obfuscated code is like putting lipstick on a pig — i.e. outside the scope of this tool.

Which browsers does it work with?

It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. Look at the test page to see if it works in your browser.

What's changed?

See the change log

Why doesn't Prettyprinting of strings work on WordPress?

Apparently wordpress does "smart quoting" which changes close quotes. This causes end quotes to not match up with open quotes.

This breaks prettifying as well as copying and pasting of code samples. See WordPress's help center for info on how to stop smart quoting of code snippets.

How do I put line numbers in my code?

You can use the linenums class to turn on line numbering. If your code doesn't start at line number 1, you can add a colon and a line number to the end of that class as in linenums:52.

For example

<pre class="prettyprint linenums:4"
>// This is line 4.
foo();
bar();
baz();
boo();
far();
faz();
<pre>
produces
// This is line 4.
foo();
bar();
baz();
boo();
far();
faz();

How do I prevent a portion of markup from being marked as code?

You can use the nocode class to identify a span of markup that is not code.

<pre class=prettyprint>
int x = foo();  /* This is a comment  <span class="nocode">This is not code</span>
  Continuation of comment */
int y = bar();
</pre>
produces
int x = foo();  /* This is a comment  This is not code
  Continuation of comment */
int y = bar();

For a more complete example see the issue22 testcase.

I get an error message "a is not a function" or "opt_whenDone is not a function"

If you are calling prettyPrint via an event handler, wrap it in a function. Instead of doing

addEventListener('load', prettyPrint, false);
wrap it in a closure like
addEventListener('load', function (event) { prettyPrint() }, false);
so that the browser does not pass an event object to prettyPrint which will confuse it.


unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/0000755000015301777760000000000012320723226032275 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016100000000000011213 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/external-small.pngunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/extern0000644000015301777760000000075312320722666033541 0ustar pbusernogroup00000000000000PNG  IHDRatEXtSoftwareAdobe ImageReadyqe<IDATxb?%B@,0]VVV0affȊ=8JO y %pJջ+30¿}sʋ`n|dx mXa |ȹWpA+ca|u=zϰp-l\w01nCy?  * Yr%cfxÿ 8 `g2ȉ0!GA[EV66>Ӏ'E]AOCAY^#.S >>#񶉝 "ÏOv%w@ FX^`ddR|8 wX  OƓIENDB`././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/main.cssunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/main.c0000644000015301777760000002421212320722666033375 0ustar pbusernogroup00000000000000/* Font sizes for all selectors other than the body are given in percentages, with 100% equal to 13px. To calculate a font size percentage, multiply the desired size in pixels by 7.6923076923. Here's a quick lookup table: 10px - 76.923% 11px - 84.615% 12px - 92.308% 13px - 100% 14px - 107.692% 15px - 115.385% 16px - 123.077% 17px - 130.769% 18px - 138.462% 19px - 146.154% 20px - 153.846% */ html { background: #fff; color: #333; overflow-y: scroll; } body { font: 13px/1.4 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Bitstream Vera Sans', 'Helvetica', 'Arial', sans-serif; margin: 0; padding: 0; } /* -- Links ----------------------------------------------------------------- */ a { color: #DD4814; text-decoration: none; } a:hover { text-decoration: underline; } /* "Jump to Table of Contents" link is shown to assistive tools, but hidden from sight until it's focused. */ .jump { position: absolute; padding: 3px 6px; left: -99999px; top: 0; } .jump:focus { left: 40%; } /* -- Paragraphs ------------------------------------------------------------ */ p { margin: 1.3em 0; } dd p, td p { margin-bottom: 0; } dd p:first-child, td p:first-child { margin-top: 0; } /* -- Headings -------------------------------------------------------------- */ h1, h2, h3, h4, h5, h6 { color: #DD4814 font-family: 'Ubuntu', sans-serif; font-weight: bold; line-height: 1.1; margin: 1.1em 0 0.5em; } h1 { font-size: 184.6%; color: #30418C; margin: 0.75em 0 0.5em; } h2 { font-size: 153.846%; color: #E48A2B; } h3 { font-size: 138.462%; } h4 { border-bottom: 1px solid #DBDFEA; color: #E48A2B; font-size: 115.385%; font-weight: normal; padding-bottom: 2px; } h5, h6 { font-size: 107.692%; } /* -- Code and examples ----------------------------------------------------- */ code, kbd, pre, samp { font-family: Menlo, Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 92.308%; line-height: 1.35; } p code, p kbd, p samp { background: #FCFBFA; border: 1px solid #EFEEED; padding: 0 3px; } a code, a kbd, a samp, pre code, pre kbd, pre samp, table code, table kbd, table samp, .intro code, .intro kbd, .intro samp, .toc code, .toc kbd, .toc samp { background: none; border: none; padding: 0; } pre.code, pre.terminal, pre.cmd { overflow-x: auto; *overflow-x: scroll; padding: 0.3em 0.6em; } pre.code { background: #FCFBFA; border: 1px solid #EFEEED; border-left-width: 5px; } pre.terminal, pre.cmd { background: #F0EFFC; border: 1px solid #D0CBFB; border-left: 5px solid #D0CBFB; } /* Don't reduce the font size of // elements inside
   blocks. */
pre code, pre kbd, pre samp { font-size: 100%; }

/* Used to denote text that shouldn't be selectable, such as line numbers or
   shell prompts. Guess which browser this doesn't work in. */
.noselect {
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    -o-user-select: none;
    user-select: none;
}

/* -- Lists ----------------------------------------------------------------- */
dd { margin: 0.2em 0 0.7em 1em; }
dl { margin: 1em 0; }
dt { font-weight: bold; }

/* -- Tables ---------------------------------------------------------------- */
caption, th { text-align: left; }

table {
    border-collapse: collapse;
    width: 100%;
}

td, th {
    border: 1px solid #fff;
    padding: 5px 12px;
    vertical-align: top;
}

td { background: #E6E9F5; }
td dl { margin: 0; }
td dl dl { margin: 1em 0; }
td pre:first-child { margin-top: 0; }

th {
    background: #D2D7E6;/*#97A0BF*/
    border-bottom: none;
    border-top: none;
    color: #000;/*#FFF1D5*/
    font-family: 'Trebuchet MS', sans-serif;
    font-weight: bold;
    line-height: 1.3;
    white-space: nowrap;
}


/* -- Layout and Content ---------------------------------------------------- */
#doc {
    margin: auto;
    min-width: 1024px;
}

#main { width: 754px; }
#sidebar { width: 270px; margin: 0 15px; }

.content { padding: 0 20px 0 25px; }

/* -- Sidebar --------------------------------------------------------------- */
.sidebox {
    background: #F9F9FC;/*E6E9F5*/
    border: 1px solid #D4D8EB;

    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;
    -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
    -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
    font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Helvetica', 'Arial', sans-serif;
    margin: 0 0 15px 0;
    padding-bottom: 1px;
}

.sidebox h2 {
    background: #E5E6F1;
    -moz-border-radius: 4px 4px 0 0;
    -webkit-border-radius: 4px 4px 0 0;
    border-radius: 4px 4px 0 0;
    color: #5E6BA4;
    font-weight: bold;
    font-size: 107.692%;
    margin: 0;
    padding: 4px 7px 5px;
}

.sidebox .bd {
    font-size: 84.615%;
    padding: 0 5px 0 8px;
}

.sidebox li { list-style-type: disc; color:#D4D5E3; }

.sidebox ol, .sidebox ul {
    margin-left: 0;
    padding-left: 16px;
}

.sidebox ol ol, .sidebox ol ul,
.sidebox ul ol, .sidebox ul ul {
    margin: 0;
    padding-left: 16px;
}

/* -- Table of Contents ----------------------------------------------------- */

/* The #toc id refers to the single global table of contents, while the .toc
   class refers to generic TOC lists that could be used throughout the page. */

.toc code, .toc kbd, .toc samp { font-size: 100%; }
.toc li { font-weight: bold; }
.toc li li { font-weight: normal; }

/* -- Intro and Example Boxes ----------------------------------------------- */
.intro, .example { margin-bottom: 2em; }

.example {
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;
    -moz-box-shadow: 0 0 5px #bfbfbf;
    -webkit-box-shadow: 0 0 5px #bfbfbf;
    box-shadow: 0 0 5px #bfbfbf;
    padding: 1em;
}

.intro {
    background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
}

/* -- Other Styles ---------------------------------------------------------- */

/* These are probably YUI-specific, and should be moved out of Selleck's default
   theme. */

.button {
    border: 1px solid #dadada;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 3px;
    color: #444;
    display: inline-block;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 92.308%;
    font-weight: bold;
    padding: 4px 13px 3px;
    -moz-text-shadow: 1px 1px 0 #fff;
    -webkit-text-shadow: 1px 1px 0 #fff;
    text-shadow: 1px 1px 0 #fff;
    white-space: nowrap;

    background: #EFEFEF; /* old browsers */
    background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
}

.button:hover {
    border-color: #466899;
    color: #fff;
    text-decoration: none;
    -moz-text-shadow: 1px 1px 0 #222;
    -webkit-text-shadow: 1px 1px 0 #222;
    text-shadow: 1px 1px 0 #222;

    background: #6396D8; /* old browsers */
    background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
}

.newwindow { text-align: center; }

.header .version em {
    display: block;
    text-align: right;
}

.yui3-skin-sam #classdocs .yui3-tabview-panel {
    background-color: transparent;
}

.yui3-skin-sam #classdocs .yui3-tabview-panel {
    border: none;
}

.yui3-skin-sam .yui3-tabview .yui3-tab,
.yui3-skin-sam .yui3-tabview .yui3-tab-selected,
.yui3-skin-sam .yui3-tabview .yui3-tab-hover {
    background: -moz-linear-gradient(center top , #F4F0EC 0%, #D6D2CE 100%) repeat scroll 0 0 transparent;
    border-bottom: 1px solid #DEDCD9;
    border-right: 1px solid #CDCBC8;
    border-left: 1px solid #CDCBC8;
    border-top: 1px solid #DADADA;
    color: #333333;
    text-decoration: none;
}
.yui3-skin-sam .yui3-tabview .yui3-tab-label,
.yui3-skin-sam .yui3-tabview .yui3-tab-selected .yui3-tab-label {
    border: none;
    background: none;
    font-size: 100%;
    color: #000;
}

.yui3-skin-sam .yui3-tabview .yui3-tab-selected,
.yui3-skin-sam .yui3-tabview .yui3-tab-hover {
    background: none;
    background-color: #fff;
    border-bottom-color: #FFFFFF;
    border-top: 2px solid #8193C9;
    font-weight: bold;
    color: #000;

}

.yui3-skin-sam .yui3-tabview-list {
    border-color: #DFDFDF;
    border-width: 0 0 1px; 
}


a.external {
    background-image: url(external-small.png);
    background-repeat: no-repeat;
    background-position: 0 0;
    padding-left: 16px;
}

#classdocs .item {
    border-bottom: 1px solid #466899;
    margin: 1em 0;
    padding: 1.5em;
}

#classdocs .item .params p,
    #classdocs .item .returns p,{
    display: inline;
}

#classdocs .item em code, #classdocs .item em.comment {
    color: green;
}

#classdocs .item em.comment a {
    color: green;
    text-decoration: underline;
}

#classdocs .foundat {
    font-size: 11px;
    font-style: normal;
}

.attrs .emits {
    margin-left: 2em;
    padding: .5em;
    border-left: 1px dashed #ccc;
}

abbr {
    border-bottom: 1px dashed #ccc;
    font-size: 80%;
    cursor: help;
}

.prettyprint li.L0, 
.prettyprint li.L1, 
.prettyprint li.L2, 
.prettyprint li.L3, 
.prettyprint li.L5, 
.prettyprint li.L6, 
.prettyprint li.L7, 
.prettyprint li.L8 {
    list-style: decimal;
}

ul li p {
    margin-top: 0;
}

.method .name {
    font-size: 110%;
}

#hd {
    background: -moz-linear-gradient(center top , #DCDBD9 0%, #F6F5F3 100%) repeat scroll 0 0 transparent;
    border-bottom: 1px solid #DFDFDF;
    padding: 0 15px 1px 20px;
    margin-bottom: 15px;
}

#hd img {
    margin-right: 10px;
    vertical-align: middle;
}

././@LongLink0000000000000000000000000000014700000000000011217 Lustar  00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/logo.pngunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/assets/css/logo.p0000644000015301777760000000135512320722666033431 0ustar  pbusernogroup00000000000000PNG


IHDR=29PLTEvO_1S#ƶl{]j@H9	pHYstIME
&	fEGIDAThv eQ;,.i]	9=Ï	QxBHB$$!	IȿTobH
L,LAJ!z2@{}q%>D*()29zfv0v'xY|~2ܾHIȔdY.Ҭ$FH[62MT%a>$XmSUhiKY.kUdYps6#È+ټV`HU2z/[Y
̷]PT&[o^|ߗuǞl 5e]6UǶEu<*5d+BoIHB$$!	JnɒőIENDB`unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/0000755000015301777760000000000012320723226032022 5ustar  pbusernogroup00000000000000././@LongLink0000000000000000000000000000015500000000000011216 Lustar  00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/props.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/props.ha0000644000015301777760000000062712320722666033513 0ustar  pbusernogroup00000000000000
`{{name}}` <{{#crossLink type}}{{/crossLink}}>{{#if final}} (final){{/if}}{{#if static}} (static){{/if}}
`{{file}}:{{line}}` {{{propertyDescription}}} {{#if example}}
Example
{{{example}}} {{/if}}
././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/module.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/module.h0000644000015301777760000000155012320722666033470 0ustar pbusernogroup00000000000000

{{moduleName}}

{{{moduleDescription}}}
{{#if moduleClasses}}

This module has the following classes:

{{/if}}
{{#if subModules}}

This module has the following submodules:

{{/if}}


Module description found: `{{file}}:{{line}}` ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/method.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/method.h0000644000015301777760000000423412320722666033465 0ustar pbusernogroup00000000000000
{{#if final}}final {{/if}}{{#if returnType}}{{#crossLink returnType}}{{/crossLink}} {{/if}}`{{name}}`( `{{paramsList}} ` ) {{#if access}}`/* {{access}} method */`{{/if}}
{{#if overwritten_from}} Defined in {{overwritten_from/class}} but overwritten locally: {{else}} {{#if extended_from}} Defined in {{extended_from}}: {{/if}} {{/if}} `{{file}}:{{line}}`
{{{methodDescription}}} {{#if params}} Parameters:
    {{#params}}
  • {{#if optional}} `[{{name}}{{#if optdefault}}={{optdefault}}{{/if}}]` <{{#crossLink type}}{{/crossLink}}> {{else}} `{{name}}` <{{#crossLink type}}{{/crossLink}}> {{/if}} {{#if multiple}} (*..n) {{/if}} {{{description}}} {{#if props}}
      {{#props}}
    • `{{name}}` <{{#crossLink type}}{{/crossLink}}> {{{description}}} {{#if props}}
        {{#props}}
      • `{{name}}` <{{#crossLink type}}{{/crossLink}}> {{{description}}}
      • {{/props}}
      {{/if}}
    • {{/props}}
    {{/if}}
  • {{/params}}
{{/if}} {{#if return}} {{#return}}
Returns: {{#if type}}<{{#crossLink type}}{{/crossLink}}> {{/if}}{{{description}}}
{{/return}} {{/if}} {{#if example}}
Example
{{{example}}} {{/if}}
././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/index.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/index.ha0000644000015301777760000000002112320722666033443 0ustar pbusernogroup00000000000000

Welcome

././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/attrs.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/attrs.ha0000644000015301777760000000257512320722666033511 0ustar pbusernogroup00000000000000
`{{name}}` {{#if type}}<{{#crossLink type}}{{/crossLink}}>{{/if}} {{#if extended_from}}`/* Extended from {{extended_from}} */`{{/if}} {{#if overwritten_from}}`/* Overwritten from {{name}} */`{{/if}}
`{{file}}:{{line}}` {{{attrDescription}}} {{#if emit}}
Fires: `{{name}}Change(e)`

Fires when the value for the configuration attribute `{{name}}` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

Parameters:
`e` <EventFacade> An Event Facade object with the following attribute specific properties added:
  • `prevVal` The value of the attribute, prior to it being set
  • `newVal` The value the attribute is to be set to
  • `attrName` The name of the attribute being set
  • `subAttrName` If setting a property within the attribute's value, the name of the sub-attribute property being set
{{/if}}
././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/files.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/files.ha0000644000015301777760000000012412320722666033442 0ustar pbusernogroup00000000000000

{{fileName}}

{{fileData}}
././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/events.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/events.h0000644000015301777760000000234412320722666033511 0ustar pbusernogroup00000000000000
`{{name}}` {{#if type}}<{{#crossLink type}}{{/crossLink}}>{{/if}} {{#if extended_from}}`/* Extended from {{extended_from}} */`{{/if}} {{#if overwritten_from}}`/* Overwritten from {{name}} */`{{/if}}
`{{file}}:{{line}}` {{{eventDescription}}} {{#if params}} Extra event object properties:
    {{#params}}
  • {{#if optional}} `[{{name}}{{#if optdefault}}={{optdefault}}{{/if}}]` <{{#crossLink type}}{{/crossLink}}> {{else}} `{{name}}` <{{#crossLink type}}{{/crossLink}}> {{/if}} {{#if multiple}} (*..n) {{/if}} {{{description}}} {{#if props}}
      {{#props}}
    • `{{name}}` <{{#crossLink type}}{{/crossLink}}> {{{description}}} {{/props}}
    {{/if}}
  • {{/params}}
{{/if}}
././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/classes.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/classes.0000644000015301777760000000324112320722666033467 0ustar pbusernogroup00000000000000

Class {{moduleName}}

{{#if uses}} Uses: {{#each uses}} {{this}} {{/each}}
{{/if}} {{#if extension_for}} Extension For: {{#each extension_for}} {{this}} {{/each}}
{{/if}} {{#if extends}} Extends: {{#crossLink extends}}{{/crossLink}}
{{/if}} Class defined in: `{{file}}:{{line}}`
{{{classDescription}}}
{{#if is_constructor}} {{#is_constructor}} {{>method}} {{/is_constructor}} {{/if}}
{{#if methods}}
{{#methods}} {{>method}} {{/methods}}
{{/if}} {{#if properties}}
{{#properties}} {{>props}} {{/properties}}
{{/if}} {{#if attrs}}
{{#attrs}} {{>attrs}} {{/attrs}}
{{/if}} {{#if events}}
{{#events}} {{>events}} {{/events}}
{{/if}}
././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/sidebar.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/partials/sidebar.0000644000015301777760000000474212320722666033452 0ustar pbusernogroup00000000000000 {{#if methods}} {{/if}} {{#if events}} {{/if}} {{#if props}} {{/if}} {{#if attributes}} {{/if}} {{#if fileTree}} {{/if}} unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/.zip0000644000015301777760000000046212320722666031017 0ustar pbusernogroup00000000000000PKiGDy_ yuidoc.jsonUT JRJRux RT%+ФҼR_SO%|JjqrQfAIf~6eV ^e`% iEP2ǂbAeEPC a```iIJfH~RifN T5X$#57*]Y R+PKiGDy_ yuidoc.jsonUTJRux PKQunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-theme/theme.json0000644000015301777760000000025512320722666032211 0ustar pbusernogroup00000000000000{ "yuiGridsUrl": "http://yui.yahooapis.com/3.8.0pr2/build/cssgrids/cssgrids-min.css", "yuiSeedUrl": "http://yui.yahooapis.com/combo?3.8.0pr2/build/yui/yui-min.js" } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/0000755000015301777760000000000012320723226030041 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/backend/0000755000015301777760000000000012320723226031430 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/backend/runtime-api.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/backend/runtime-ap0000644000015301777760000001374112320722666033451 0ustar pbusernogroup00000000000000/* * Copyright 2014 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ .import Ubuntu.UnityWebApps 0.1 as UnityWebAppsBridge .import Ubuntu.Components 0.1 as ComponentsBridge /** * * Runtime API backend binding * */ function createRuntimeApi(backendDelegate) { var PLUGIN_URI = 'Ubuntu.UnityWebApps'; var VERSION = 0.1; var applicationApiInstance = UnityWebAppsBridge.ApplicationApi; function Application() { // no need to have a specific id since this class is mostly a passtrough one this._id = 0; }; Application.prototype = { // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'RuntimeApi', objecttype: 'Application', objectid: this._id, content: { name: applicationApiInstance.applicationName, platform: applicationApiInstance.applicationPlatform, writableLocation: applicationApiInstance.applicationDataPath, screenOrientation: applicationApiInstance.screenOrientation, inputMethodName: applicationApiInstance.getInputMethodName(), } } }, getApplicationName: function(callback) { if (callback && typeof(callback) === 'function') callback(applicationApiInstance.applicationName); }, onApplicationNameChanged: function(callback) { if (callback && typeof(callback) === 'function') applicationApiInstance.applicationNameChanged.connect(function() { callback(applicationApiInstance.applicationName); }); }, getApplicationWritableLocation: function(callback) { if (callback && typeof(callback) === 'function') callback(applicationApiInstance.applicationDataPath); }, getPlatformInfo: function(callback) { if (callback && typeof(callback) === 'function') { var info = {}; info.name = applicationApiInstance.applicationPlatform; callback(info); } }, setInputMethodVisible: function(visible, callback) { applicationApiInstance.setInputMethodVisible(visible); if (callback && typeof(callback) === 'function') callback(); }, getInputMethodName: function(callback) { if (callback && typeof(callback) === 'function') callback(applicationApiInstance.getInputMethodName()); }, onInputMethodVisibilityChanged: function(callback) { if (callback && typeof(callback) === 'function') Qt.inputMethod.onVisibleChanged.connect(function() { callback(Qt.inputMethod.visible) }); }, onAboutToQuit: function(callback) { if (callback && typeof(callback) === 'function') applicationApiInstance.applicationAboutToQuit.connect(function(killed) { callback(killed); }); }, setupUriHandler: function(callback) { if (callback && typeof(callback) === 'function') var urihandler = ComponentsBridge.UriHandler; urihandler.opened.connect(function(uris, data) { var translatedUris = [] for (var idx in uris) { translatedUris.push(uris[idx]) } callback(translatedUris); }); }, onDeactivated: function(callback) { if (callback && typeof(callback) === 'function') applicationApiInstance.applicationDeactivated.connect(callback); }, onActivated: function(callback) { if (callback && typeof(callback) === 'function') applicationApiInstance.applicationActivated.connect(callback); }, getScreenOrientation: function(callback) { if (callback && typeof(callback) === 'function') callback(applicationApiInstance.screenOrientation); }, onScreenOrientationChanged: function(callback) { if (callback && typeof(callback) === 'function') applicationApiInstance.applicationScreenOrientationChanged.connect(callback); }, }; function _constructorFromName(className) { var constructorPerName = { "Application": Application, }; return className in constructorPerName ? constructorPerName[className] : null; } return { getApplication: function(callback) { var application = new Application(); callback(application.serialize()); }, // Internal dispatchToObject: function(infos) { var args = infos.args; var callback = infos.callback; var method_name = infos.method_name; var objectid = infos.objectid; var class_name = infos.class_name; if (callback) args.push(callback); var Constructor = _constructorFromName(class_name); var instance = new Constructor(objectid); instance[method_name].apply(instance, args); } }; } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/client/0000755000015301777760000000000012320723226031317 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/client/yuidoc.json0000644000015301777760000000033712320722666033520 0ustar pbusernogroup00000000000000{ "name": "Runtime JS API", "description": "Ubuntu App Platform Runtime JavaScript API docs", "version": "0.1", "options": { "outdir": "./docsbuild", "themedir": "../../yuidoc-theme" } } ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/client/index.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/client/index.handl0000644000015301777760000000006712320722666033450 0ustar pbusernogroup00000000000000

Welcome to Ubuntu Runtime Javascript API Docs

././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/client/runtime-api.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/runtime-api/client/runtime-api0000644000015301777760000002131112320722666033501 0ustar pbusernogroup00000000000000/* * Copyright 2014 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ /** * RuntimeApi gives access to the application runtime information and management. * @module RuntimeApi */ function createRuntimeApi(backendBridge) { var PLUGIN_URI = 'RuntimeApi'; function Application(id, content) { this._proxy = backendBridge.createRemoteObject( PLUGIN_URI, 'Application', id); this._name = content.name; this._platform = content.platform; this._writableLocation = content.writableLocation; this._screenOrientation = content.screenOrientation; this._inputMethodName = content.inputMethodName; this._setupPropertyListeners(); }; Application.prototype = { /** * Internal */ _setupPropertyListeners: function() { var self = this; this._proxy.call('onApplicationNameChanged' , [function(name) {self._name = name;}]); this._proxy.call('onScreenOrientationChanged' , [function(orientation) {self._screenOrientation = orientation;}]); }, /** * Retrieves the application name. * * @method getApplicationName * @return {String} application name */ getApplicationName: function() { return this._name; }, /** * Sets up a callback that is to be called when the application's name changed. * * @method onApplicationNameChanged * @param callback {Function(String)} Function to be called when the application's name has changed. */ onApplicationNameChanged: function(callback) { var self = this; this._proxy.call('onApplicationNameChanged' , [callback]); }, /** * Retrieves the fileystem location where the application is allowed to write its data in. * * @method getApplicationWritableLocation * @return {String} application writable location path */ getApplicationWritableLocation: function() { return this._writableLocation; }, /** * Retrieves current platform information. * * @method getPlatformInfos * @return {Object} platform information as a dictionary with the following keys: * - name: the platform name */ getPlatformInfo: function() { return this._platform; }, /** * Sets up a callback that is to be called when the application is about to quit. * * @method onAboutToQuit * @param callback {Function()} Function to be called when the application is about to quit. */ onAboutToQuit: function(callback) { this._proxy.call('onAboutToQuit' , [callback]); }, /** * Sets up a callback that is to be called when the application has been deactivated (background). * * @method onDeactivated * @param callback {Function()} Function to be called when the application has been deactivated. */ onDeactivated: function(callback) { this._proxy.call('onDeactivated' , [callback]); }, /** * Sets up a callback that is to be called when the application has been activated (from background). * * @method onActivated * @param callback {Function()} Function to be called when the application has been activated. */ onActivated: function(callback) { this._proxy.call('onActivated' , [callback]); }, /** * Retrieves the current screen orientation. * * @method getScreenOrientation * @return {ScreenOrientation} current screen orientation. */ getScreenOrientation: function() { return this._screenOrientation; }, /** * Sets up a callback that is to be called when the application's screen has changed its orientation. * * @method onScreenOrientationChanged * @param callback {Function(ScreenOrientation)} Function to be called when the application's screen orientation has changed. */ onScreenOrientationChanged: function(callback) { var self = this; this._proxy.call('onScreenOrientationChanged' , [callback]); }, /** * Sets up a URI handler. The application can be sent URIs to open. * * @method setupUriHandler * @param callback {Function([String])} Function to be called with the current list of uris to open */ setupUriHandler: function(callback) { this._proxy.call('setupUriHandler' , [callback]); }, /** * Retrieves the current input method's name. The name varies depending on the platform * e.g. maliit can be part of the name for a maliit based Virtual Keyboard (possibly mangled * with e.g. 'phablet'), when a keyboard is there the name can be empty, ... * * @method getInputMethodName * @return {String} current input method name */ getInputMethodName: function() { return this._inputMethodName; }, /** * Sets up a callback that is to be called when the On Screen Keyboard visibility has changed. * * @method onInputMethodVisibilityChanged * @param callback {Function(Bool)} Function to be called when the On Screen Keyboard visibility has changed (received the visibility as an arg). */ onInputMethodVisibilityChanged: function(callback) { this._proxy.call('onInputMethodVisibilityChanged' , [callback]); } }; function _constructorFromName(className) { var constructorPerName = { "Application": Application, }; return className in constructorPerName ? constructorPerName[className] : null; }; /** * The RuntimeApi object * @class RuntimeApi * @constructor * @example var api = external.getUnityObject('1.0'); api.RuntimeApi.getApplication(function(application) { console.log('Application name: ' + application.getApplicationName()); }); */ return { /** Enumeration of the available types of ScreenOrientation. Values: Landscape: The application screen is in landscape mode InvertedLandscape: The application screen is in inverted landscape mode Portrait: The application screen is in portrait mode InvertedPortrait: The application screen is in inverted portrait mode Unknown: The application screen is in an unknown mode @static @property ScreenOrientation {Object} @example var api = external.getUnityObject('1.0'); var orientation = api.RuntimeApi.ScreenOrientation; // use orientation.Landscape or orientation.Portrait */ ScreenOrientation: { Landscape: "Landscape", InvertedLandscape: "InvertedLandscape", Portrait: "Portrait", InvertedPortrait: "InvertedPortrait", Unknwon: "Unknown", }, /** * Creates an Application object. * * @method getApplication * @param callback {Function (Application)} */ getApplication: function(callback) { backendBridge.call('RuntimeApi.getApplication' , [] , callback); }, /** * @private * */ createObjectWrapper: function(objectType, objectId, content) { var Constructor = _constructorFromName(objectType); return new Constructor(objectId, content); }, }; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/DOCS-README0000644000015301777760000000075012320722666027226 0ustar pbusernogroup00000000000000To build docs for the known apis: Install yuidocs as described here: https://bugs.launchpad.net/ubuntu-html5-theme/+bug/1241029/comments/16 Run yuidoc-build.sh Docs are generated in each API/client/docsbuild, for example in: * alarm-api/client/docsbuild To add new api directories for autobuilding: * Add the dir to the for loop in yuidocs-build.sh * Add the following to the NEWAPI/client/ dir - yudioc.json filei, edited accordingly - index.handlebars file,, edited accordinly unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/yuidoc-build.sh0000755000015301777760000000061312320722666030546 0ustar pbusernogroup00000000000000#/bin/bash set -e for api in alarm-api content-hub online-accounts runtime-api ; do echo $api cd $api/client mv ../../yuidoc-theme/partials/index.handlebars index.handlebars.orig cp index.handlebars ../../yuidoc-theme/partials/ rm -rf ./docsbuild yuidoc -c yuidoc.json . mv index.handlebars.orig ../../yuidoc-theme/partials/index.handlebars cd ../.. done; exit 0 unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/0000755000015301777760000000000012320723226027452 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/backend/0000755000015301777760000000000012320723226031041 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/client/0000755000015301777760000000000012320723226030730 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/client/yuidoc.json0000644000015301777760000000033512320722666033127 0ustar pbusernogroup00000000000000{ "name": "Alarms JS API", "description": "Ubuntu App Platform Alarms JavaScript API docs", "version": "0.1", "options": { "outdir": "./docsbuild", "themedir": "../../yuidoc-theme" } } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/client/index.handlebarsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/client/index.handleb0000644000015301777760000000006612320722666033367 0ustar pbusernogroup00000000000000

Welcome to Ubuntu Alarms JavaScript API Docs

unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/bindings/alarm-api/client/alarm-api.js0000644000015301777760000003515712320722666033153 0ustar pbusernogroup00000000000000/** * AlarmApi gives access to Alarm management. * @module AlarmApi */ function createAlarmApi(backendBridge) { var PLUGIN_URI = 'Alarm'; /** * An Alarm. * @class Alarm * @constructor * @example var date = new Date(); var api = external.getUnityObject('1.0'); api.AlarmApi.api.createAndSaveAlarmFor( date, api.AlarmApi.AlarmType.OneTime, api.AlarmApi.AlarmDayOfWeek.AutoDetect, "alarm triggered", function(errorid) { console.log(api.AlarmApi.api.errorToMessage(errorid)); }); */ function Alarm(id) { this._proxy = backendBridge.createRemoteObject( PLUGIN_URI, 'Alarm', id); }; Alarm.prototype = { // properties /** * The property holds the error code occurred during the last performed operation. * * @method error * @param callback {Function(Error)} */ error: function(callback) { this._proxy.call('error', [], callback); }, /** * Retrieves the alarm date. * * The date property holds the date the alarm will be triggered. * The default value is the current date and time the alarm object was created. * Further reset calls will bring the value back to the time the reset was called. * * @method error * @param callback {Function(Date)} */ date: function(callback) { this._proxy.call('date', [] , function(datems) { var d = new Date(); d.setTime(datems); return d; }); }, /** * Sets the alarm date. * * @method setDate * @param date {Date} * @param callback (optional) {Function()} To be called after the date is set. */ setDate: function(date, callback) { this._proxy.call('setDate', [date.getTime(), callback]); }, /** * Retrieves the alarm's enabled state. * * The property specifies whether the alarm is enabled or not. * Disable dalarms are not scheduled. The default value is true * * @method enabled * @param callback {Function(Boolean)} */ enabled: function(callback) { this._proxy.call('enabled', [], callback); }, /** * Sets the alarm's enabled state. * * @method setEnabled * @param enabled {Boolean} * @param callback (optional) {Function()} To be called after the enabled state is set. */ setEnabled: function(enabled, callback) { this._proxy.call('setEnabled', [enabled, callback]); }, /** * Retrieves the alarm message. * * The property holds the message string which will be displayed when the alarm is triggered. * The default value is the localized "Alarm" text * * @method message * @param callback {Function(String)} */ message: function(callback) { this._proxy.call('message', [], callback); }, /** * Sets the alarm message. * * @method setMessage * @param message {String} * @param callback (optional) {Function()} To be called after the message is set. */ setMessage: function(message, callback) { this._proxy.call('setMessage', [message, callback]); }, /** * Retrieves the alarm sound. * * The property holds the alarm's sound to be played when the alarm is triggered. * An empty url will mean to play the default sound. * * The default value is an empty url. * * @method sound * @param callback {Function(String)} */ sound: function(callback) { this._proxy.call('sound', [], callback); }, /** * Sets the alarm sound. * * @method setSound * @param sound {String} * @param callback (optional) {Function()} To be called after the sound is set. */ setSound: function(sound, callback) { this._proxy.call('setSound', [sound, callback]); }, /** * Retrieves the alarm status. * * The property holds the status of the last performed operation * * @method status * @param callback {Function(String)} */ status: function(callback) { this._proxy.call('status', [], callback); }, /** * Retrieves the alarm type. * * The property holds the type of the alarm. * The default value is AlarmType.OneTime * * @method type * @param callback {Function(AlarmType)} */ type: function(callback) { this._proxy.call('type', [], callback); }, /** * Sets the alarm type. * * @method setType * @param type {AlarmType} * @param callback (optional) {Function()} To be called after the type is set. */ setType: function(type, callback) { this._proxy.call('setType', [type, callback]); }, /** * Retrieves the alarm day of the week. * * The property holds the days of the week the alarm is scheduled. * This property can have only one day set for one time alarms and multiple days for repeating alarms. * * @method daysOfWeek * @param callback {Function(AlarmType)} */ daysOfWeek: function(callback) { this._proxy.call('daysOfWeek', [], callback); }, /** * Sets the alarm day of the week. * * @method setDaysOfWeek * @param daysOfWeek {AlarmDayOfWeek} * @param callback (optional) {Function()} To be called after the day of the week is set. */ setDaysOfWeek: function(daysOfWeek, callback) { this._proxy.call('setDaysOfWeek', [daysOfWeek, callback]); }, // methods /** * Cancels a given Alarm. * * @method cancel */ cancel: function() { this._proxy.call('cancel', []); }, /** * Resets a given Alarm. * * @method reset */ reset: function() { this._proxy.call('reset', []); }, /** * Saves the alarm as a system wide alarm with the parameters previously set. * * @method save */ save: function() { this._proxy.call('save', []); }, // extras /** * Destroys the remote object. This proxy object is not valid anymore. * * @method destroy */ destroy: function() { this._proxy.call('destroy', []); }, }; function _constructorFromName(className) { var constructorPerName = { "Alarm": Alarm, }; return className in constructorPerName ? constructorPerName[className] : null; }; /** * The AlarmApi object * @class AlarmApi * @constructor * @example var date = new Date(); var api = external.getUnityObject('1.0'); api.AlarmApi.api.createAndSaveAlarmFor( date, api.AlarmApi.AlarmType.OneTime, api.AlarmApi.AlarmDayOfWeek.AutoDetect, "alarm triggered", function(errorid) { console.log(api.AlarmApi.api.errorToMessage(errorid)); }); */ return { /** Enumeration of the available types of Alarm. Values: OneTime: The alarm occurs only once Repeating: The alarm is a repeating one, either daily, weekly on a given day or on selected days @static @property AlarmType {Object} @example var api = external.getUnityObject('1.0'); var alarmtype = api.AlarmApi.AlarmType; // use alarmtype.OneTime or alarmtype.Repeating */ AlarmType: { // The alarm occurs only once. OneTime: "OneTime", // The alarm is a repeating one, either daily, weekly on a given day or on selected days. Repeating: "Repeating", }, /** Flags for the week days an Alarm should be triggered. Values: Monday: The alarm will kick on Mondays Tuesday: The alarm will kick on Tuesdays Wednesday: The alarm will kick on Wednesday Thursday: The alarm will kick on Thursday Friday: The alarm will kick on Friday Saturday: The alarm will kick on Saturday Sunday: The alarm will kick on Sunday AutoDetect: The alarm day will be detected from the alarm date. @static @property AlarmDayOfWeek {Integer} @example var api = external.getUnityObject('1.0'); var dayofweek = api.AlarmApi.AlarmDayOfWeek; // use dayofweek.Monday or/and dayofweek.Tuesday, etc. */ AlarmDayOfWeek: { // The alarm will kick on Mondays. Monday: 1, // The alarm will kick on Tuesdays. Tuesday: 2, // The alarm will kick on Wednesdays. Wednesday: 4, // The alarm will kick on Thursdays. Thursday: 8, // The alarm will kick on Fridays. Friday: 16, // The alarm will kick on Saturdays. Saturday: 32, // The alarm will kick on Sundays. Sunday: 64, // The alarm day will be detected from the alarm date. AutoDetect: 128, }, /** Error ids returned during AlarmApi calls. Values: NoError: Successful operation completion InvalidDate: The date specified for the alarm was invalid EarlyDate: The date specified for the alarm is an earlier date than the current one NbDaysOfWeek: The daysOfWeek parameter of the alarm was not specified OneTimeOnMoreDays: The one-time alarm was set to be kicked in several days InvalidEvent: The alarm event is invalid AdaptationError: The error occurred in alarm adaptation layer. Adaptations may define additional behind this value @static @property AlarmError {Integer} @example var date = new Date(); var api = external.getUnityObject('1.0'); api.AlarmApi.api.createAndSaveAlarmFor( date, api.AlarmApi.AlarmType.OneTime, api.AlarmApi.AlarmDayOfWeek.AutoDetect, "alarm triggered", function(errorid) { console.log(api.AlarmApi.api.errorToMessage(errorid)); }); */ AlarmError: { // Successful operation completion NoError: 0, // The date specified for the alarm was invalid InvalidDate: 1, // The date specified for the alarm is an earlier date than the current one EarlyDate: 2, // The daysOfWeek parameter of the alarm was not specified NoDaysOfWeek: 3, // The one-time alarm was set to be kicked in several days OneTimeOnMoreDays: 4, // The alarm event is invalid InvalidEvent: 5, // The error occurred in alarm adaptation layer. Adaptations may define additional behind this value AdaptationError: 6, }, /** * Creates a Alarm object. * * @method createAlarm * @param callback {Function(Alarm)} Function called with the created Alarm. */ createAlarm: function(callback) { backendBridge.call('Alarm.createAlarm' , [] , callback); }, api: { /** * Creates and saves a new alarm. * * @method api.createAndSaveAlarmFor * @param date {Date} date at which the alarm is to be triggered. * @param type {AlarmType} type of the alarm. * @param daysOfWeek {AlarmDayOfWeek} days of the week the alarm is scheduled. * @param message {String} Message to be displayed when the alarm is triggered. * @param callback (optional) {Function(AlarmError)} Function to be called when the alarm has been saved. */ createAndSaveAlarmFor: function(date, type, daysOfWeek, message, callback) { backendBridge.call('Alarm.createAndSaveAlarmFor' , [date.getTime(), type, daysOfWeek, message, callback]); }, /** * Returns a message adapted to the given error id. * * @method api.errorToMessage * @param error {AlarmError} error id. */ errorToMessage: function(error) { var messagePerError = [ "Successful operation completion", "The date specified for the alarm was invalid", "The date specified for the alarm is an earlier date than the current one", "The daysOfWeek parameter of the alarm was not specified", "The one-time alarm was set to be kicked in several days", "The alarm event is invalid", "The error occurred in alarm adaptation layer" ]; return error < messagePerError.length ? messagePerError[error] : "Invalid error id"; }, }, // Internal /** * @private * */ createObjectWrapper: function(objectType, objectId, content) { var Constructor = _constructorFromName(objectType); return new Constructor(objectId, content); }, }; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/UnityWebApps.qml0000644000015301777760000006125512320722666027137 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import Ubuntu.UnityWebApps 0.1 as UbuntuUnityWebApps import "UnityWebApps.js" as UnityWebAppsJs import "UnityWebAppsUtils.js" as UnityWebAppsJsUtils import "UnityWebAppsBackendComponents.js" as UnityBackends import "./bindings/runtime-api/backend/runtime-api.js" as RuntimeApiBackend /*! \qmltype UnityWebApps \inqmlmodule Ubuntu.UnityWebApps 0.1 \ingroup ubuntu \brief The QML component that binds to a QML WebView and exposes the Unity WebApps API to it's javascript. Examples: \qml UnityWebApps { id: webapps name: "MyApp" bindee: webView } \endqml On the page's javascript side, an event is being sent to the document when the API is exposed and ready to be used: "ubuntu-webapps-api-ready". So a typical pattern for the page's javascript could be: \code function init() { // The Unity APIs are available throuhg external.getUnityObject var Unity = external.getUnityObject(1); } if (!external.getUnityObject) { document.addEventListener ("ubuntu-webapps-api-ready", function () { init(); }); } \endcode */ Item { id: webapps /*! \qmlproperty string UnityWebApps::name Holds the name of the application that is run as a WebApp. It should be used in conjunction with a model. The 'name' property is then used while looking up for the webapp in the set of locally installed ones. The name should not change once it has been set. (?) */ property string name: "" /*! \qmlproperty string UnityWebApps::bindee Holds a reference to the object that webapps are to be injected in. The UnityWebApps QML component expects any bindee to duck-type with the following IDL signature: \code method getUnityWebappsProxies() \endcode that should return a BindeeExports: \code interface BindeeExports { method injectUserScripts(string userScriptUrls); method sendToPage(string message); method loadingStartedConnect(Callback onLoadingStarted); method messageReceivedConnect(Callback onMessageReceived); method navigateTo(string url); } \endcode */ property var bindee /*! \qmlproperty UnityWebappsAppModel UnityWebApps::model An optional model used in conjunction with the 'name' property as a location for looking up the desired webapps. */ property var model: null /*! \qmlproperty UnityWebappsAppModel UnityWebApps::extraApisSource An optional model used in conjunction with the 'name' property as a location for looking up the desired webapps. */ property alias injectExtraUbuntuApis: settings.injectExtraUbuntuApis /*! \qmlproperty UnityWebappsAppModel UnityWebApps::extraApisSource */ property alias requiresInit: settings.requiresInit /*! \qmlproperty UnityActions.Context UnityWebApps::actionsContext The actions context that this element can reach out to for additional actions. */ property var actionsContext: null /*! \qmlproperty string UnityWebApps::_opt_backendProxies Used only for testing. Allows optional (not the default ones) mocked backends to be used. */ property var _opt_backendProxies: null Settings { id: settings } /* Loader { id: apiBindingModelComponentLoader sourceComponent: settings.injectExtraUbuntuApis ? apiBindingModelComponent : undefined } */ /*! \internal PRIVATE FUNCTION: __bind Binds a given webapp object with something that is expected to support the following calls: \code interface BindeeExports { method injectUserScripts(string userScriptUrls); method sendToPage(string message); method loadingStartedConnect(Callback onLoadingStarted); method messageReceivedConnect(Callback onMessageReceived); method navigateTo(string url); } \endcode The bindee should not be null. */ function __bind(bindee, webappUserscripts) { if (!bindee) { console.debug('__bind: ERROR Invalid bindee when trying to bind the QML WebApps component') return; } if (internal.instance) { console.debug('__bind: ERROR Instance already set') return; } if (!__isValidBindee(bindee)) { console.debug('__bind: ERROR not a valid bindee') return; } // Get an instance of the bridging interface that // the bindee is supposed to provide. var bindeeProxies = bindee.getUnityWebappsProxies(); if (!__areValidBindeeProxies(bindeeProxies)) { console.debug('__bind: ERROR bindee proxies not valid') return; } var backends = __createBackendsIfNeeded(); var instance = new UnityWebAppsJs.UnityWebApps(webapps, bindeeProxies, backends, webappUserscripts); internal.backends = backends; internal.instance = instance; } /*! \internal */ function __createBackendsIfNeeded() { var backends; if (_opt_backendProxies != null) backends = _opt_backendProxies; else { backends = __makeBackendProxies(); } return backends; } /*! \internal PRIVATE FUNCTION: __isValidBindee */ function __isValidBindee(bindee) { var properties = [{'name': 'getUnityWebappsProxies', 'type': 'function'}]; var validator = UnityWebAppsJsUtils.makePropertyValidator(properties); return validator(bindee); } /*! \internal PRIVATE FUNCTION: __areValidBindeeProxies Validates the bindeed proxies as exported by getUnityWebappsProxies */ function __areValidBindeeProxies(proxies) { var properties = [{'name': 'sendToPage', 'type': 'function'}, {'name': 'loadingStartedConnect', 'type': 'function'}, {'name': 'messageReceivedConnect', 'type': 'function'}, {'name': 'injectUserScripts', 'type': 'function'}, {'name': 'navigateTo', 'type': 'function'}]; var validator = UnityWebAppsJsUtils.makePropertyValidator(properties); return validator(proxies); } /*! \internal PRIVATE FUNCTION: __reset */ function __reset() { __unbind(); if (typeof(name) === 'string' && name !== "") UnityBackends.clearAll(); } /*! \internal PRIVATE FUNCTION: __unbind */ function __unbind() { //TODO: make sure that now leaks here if (internal.instance) internal.instance.cleanup(); internal.instance = null; internal.backends = null; } /*! \internal Validates that an installed webapp has been found in the current model (if any) given the webapp name. */ function __isValidWebAppForModel(webappName) { return __isValidWebAppName(webappName) && model != null && model.exists && model.exists(webappName); } /*! \internal Gathers the webapps userscript associated with the webapp whose name is passed as param. Returns the list of URIs for the associated scripts to be injected */ function __gatherWebAppUserscriptsIfAny(webappName) { var userscripts = []; if (__isValidWebAppForModel(webappName)) { var idx = model.getWebappIndex(webappName); userscripts = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Scripts); // FIXME: hack userscripts = userscripts.map(function (script) { return 'file://' + script; }); } return userscripts; } /*! \internal If the component has been binded to a proper bindee (exposes proper interface) and the webapps bridge has been initialized, this make sure that the bindee is requested to navigate to a given 'homepage' url for the associated webapp. */ function __navigateToWebappHomepageInBindee(webappName) { if (__isValidWebAppForModel(webappName) && internal.instance) { var idx = model.getWebappIndex(webappName); var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage); console.debug('Requesting the bindee to navigate to homepage: ' + homepage); // We recreate a bindee object, but we call any function that requires // come custom cleanup (signals), so we are ok. var bindeeProxies = bindee.getUnityWebappsProxies(); bindeeProxies.navigateTo(homepage); } } /*! \internal */ function __initWebappForName(name) { webapps.__unbind(); if (bindee != null) webapps.__bind(bindee, __isValidWebAppForModel(name) ? __gatherWebAppUserscriptsIfAny(name) : null); if (__isValidWebAppName(name)) { __navigateToWebappHomepageInBindee(name); } } Component.onCompleted: { function oncompleted() { __initWebappForName(name); } if ( ! internal.instance) oncompleted(); if (model) { model.modelChanged.connect(oncompleted); } internal.componentComplete = true; } /*! \internal */ onBindeeChanged: { //FIXME: we shouldn't allow bindee to change } /*! \internal */ onNameChanged: { //FIXME: we shouldn't allow webapp names to change if (internal.componentComplete) __initWebappForName(name); } /*! \internal */ QtObject { id: internal property var instance: null property var backends: null property bool componentComplete: false } /*! \internal */ function __isValidWebAppName(name) { return name != null && typeof(name) === 'string' && name != ""; } /*! \internal */ function __injectResourceIfExtraApisAreEnabled(getResourceFunc) { if (getResourceFunc && typeof getResourceFunc === 'function' && injectExtraUbuntuApis) { return getResourceFunc(); } return null; } /*! \internal PRIVATE FUNCTION: __makeBackendProxies Binds the API dispatched calls to the Unity backends. TODO move elsewhere (in js file) */ function __makeBackendProxies () { var initialized = settings.requiresInit ? false : true; function getWrappedJsCallback(jscallback) { var callback = Qt.createQmlObject('import Ubuntu.UnityWebApps 0.1 as Backends; Backends.UnityWebappsCallback { }', bindee); callback.onTriggered.connect(jscallback); return callback; }; function isValidInitCall(params) { if (! params) return false; if (params.__unity_webapps_hidden && params.__unity_webapps_hidden.local) return true; if (! params.__unity_webapps_hidden || ! params.__unity_webapps_hidden.hostname) { console.debug('Cannot find hidden initialization param'); return false; } if ( ! params.domain || typeof(params.domain) !== 'string' || params.domain.length === 0) { console.debug('Cannot find a "domain" property'); return false; } return params.__unity_webapps_hidden.hostname.indexOf(params.domain) !== -1; }; UnityBackends.createBackendDelegate(webapps); return { init: function (params) { if (! isValidInitCall(params)) { return; } function callOnInitScriptFunc() { if (params.onInit && typeof(params.onInit) === 'function') { params.onInit(); } } if ( ! initialized) { // The 'name' property takes over the params.name property // if any is set. var webappName = name ? name : params.name; // We should be all set & ready for the backends UnityBackends.clearAll(); UnityBackends.createAllWithAsync(webapps, {name: webappName, displayName: params.name}, internal.instance ? internal.instance.proxies() : null); UnityBackends.signalOnBackendReady("base", function () { var base = UnityBackends.get("base"); function onInitCompleted(success) { console.debug('Received initCompleted signal, status: ' + success); base.initCompleted.disconnect(onInitCompleted); if (success) { initialized = true; callOnInitScriptFunc(); } }; base.initCompleted.connect(onInitCompleted); var isLocal = params.__unity_webapps_hidden && params.__unity_webapps_hidden.local; var url = params.__unity_webapps_hidden && params.__unity_webapps_hidden.url ? params.__unity_webapps_hidden.url : ""; base.init(webappName, url, isLocal, params); }); } else { callOnInitScriptFunc(); } }, addAction: function(actionName, onActionInvoked) { if (!initialized) return; // hud add action UnityBackends.get("hud").addAction(actionName, onActionInvoked); }, clearAction: function(actionName) { if (!initialized) return; // hud remove action UnityBackends.get("hud").clearAction(actionName); }, clearActions: function() { if (!initialized) return; // hud remove all action UnityBackends.get("hud").clearActions(); }, Notification: { showNotification: function (summary, body, iconUrl) { if (!initialized) return; //TODO: fix that underterministic crap ("notify" being badly independantly // checked from the others) UnityBackends.signalOnBackendReady("notify", function () { UnityBackends.get("notify").show(summary, body, iconUrl); }); } }, MessagingIndicator: { showIndicator: function (name, properties) { if (!initialized) return; UnityBackends.get("messaging").showIndicator(String(name)); for (var i in properties) { if (i === "time") { UnityBackends.get("messaging").setProperty(String(name), i, UnityWebAppsJsUtils.toISODate(properties[i])); } else if (i === "count") { UnityBackends.get("messaging").setProperty(String(name), i, String(Number(properties[i]))); } else if (i === "callback") { UnityBackends.get("messaging").setProperty(String(name), i, getWrappedJsCallback (properties[i])); } else { UnityBackends.get("messaging").setProperty(String(name), i, properties[i]); } } }, clearIndicator: function (name) { if (!initialized) return; UnityBackends.get("messaging").clearIndicator(name); }, clearIndicators: function () { if (!initialized) return; UnityBackends.get("messaging").clearIndicators(); }, addAction: function (name, onActionInvoked) { if (!initialized) return; var id = UnityBackends.get("base").addIndicatorAction(name); UnityBackends.get("indicator-actions").addAction(name, onActionInvoked, id); }, }, MediaPlayer: { init: function () { console.debug('MediaPlayer.init is deprecated'); }, setTrack: function (infos) { if (!initialized) return; var album = infos.album || ''; var artist = infos.artist || ''; var title = infos.title || ''; var artLocation = ""; UnityBackends.get("mediaplayer").setTrack(artist, album, title, artLocation); }, onPrevious: function (callback) { UnityBackends.get("mediaplayer").onPrevious(getWrappedJsCallback (callback)); }, onNext: function (callback) { UnityBackends.get("mediaplayer").onNext(getWrappedJsCallback (callback)); }, onPlayPause: function (callback) { UnityBackends.get("mediaplayer").onPlayPause(getWrappedJsCallback (callback)); }, getPlaybackCtate: function (callback) { callback (UnityBackends.get("mediaplayer").getPlaybackState()); }, setPlaybackState: function (state) { UnityBackends.get("mediaplayer").setPlaybackState(state); }, setCanGoNext: function (cango) { UnityBackends.get("mediaplayer").setCanGoNext(cango); }, setCanGoPrevious: function (cango) { UnityBackends.get("mediaplayer").setCanGoPrevious(cango); }, setCanPlay: function (canplay) { UnityBackends.get("mediaplayer").setCanPlay(canplay); }, setCanPause: function (canpause) { UnityBackends.get("mediaplayer").setCanPause(canpause); }, __get: function (prop, callback) { if (!initialized) return; if (prop === "can-go-previous") { callback(UnityBackends.get("mediaplayer").getCanGoPrevious()); } else if (prop === "can-go-next") { callback(UnityBackends.get("mediaplayer").getCanGoNext()); } else if (prop === "can-play") { callback(UnityBackends.get("mediaplayer").getCanPlay()); } else if (prop === "can-pause") { callback(UnityBackends.get("mediaplayer").getCanPause()); } else if (prop === "track") { callback(UnityBackends.get("mediaplayer").getTrack()); } } }, OnlineAccounts: __injectResourceIfExtraApisAreEnabled(function() { return UnityBackends.createOnlineAccountsApi(UnityBackends.backendDelegate) }), Alarm: __injectResourceIfExtraApisAreEnabled(function() { return UnityBackends.createAlarmApi(UnityBackends.backendDelegate) }), ContentHub: __injectResourceIfExtraApisAreEnabled(function() { return UnityBackends.createContentHubApi(UnityBackends.backendDelegate) }), RuntimeApi: RuntimeApiBackend.createRuntimeApi(UnityBackends.backendDelegate), Launcher: { setCount: function (count) { if (!initialized) return; UnityBackends.get("launcher").setCount(count); }, clearCount: function () { if (!initialized) return; UnityBackends.get("launcher").clearCount(); }, setProgress: function (progress) { if (!initialized) return; UnityBackends.get("launcher").setProgress(progress); }, clearProgress: function () { if (!initialized) return; UnityBackends.get("launcher").clearProgress(); }, setUrgent: function () { if (!initialized) return; UnityBackends.get("launcher").setUrgent(); }, addStaticAction: function (name, url) { if (!initialized) return; if (this.__actionNames[name]) this.removeAction(name); var id = UnityBackends.get("base").addStaticAction(name, url); this.__actionNames[name] = id; }, addAction: function (name, ontriggered) { if (!initialized) return; if (this.__actionNames[name]) this.removeAction(name); var id = UnityBackends.get("base").addLauncherAction(name); UnityBackends.get("indicator-actions").addAction(name, function () { console.debug(name + " triggered"); ontriggered(); }, id); this.__actionNames[name] = id; }, removeAction: function (name) { if (!initialized) return; if ( ! (name in this.__actionNames)) return; UnityBackends.get("base").removeLauncherAction(name, this.__actionNames[name]); UnityBackends.get("indicator-actions").clearAction(name); delete this.__actionNames[name]; }, removeActions: function () { if (!initialized) return; UnityBackends.get("base").removeLauncherActions(); for (var name in this.__actionNames) { this.removeActions(name); } }, __get: function (prop, callback) { if (!initialized) return; if (prop === "progress") { callback(UnityBackends.get("launcher").getProgress()); } else if (prop === "count") { callback(UnityBackends.get("launcher").getCount()); } }, __actionNames: {} } }; } } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/0000755000015301777760000000000012320723226025310 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-common-priv.h0000644000015301777760000000243112320722666032543 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_TOOLS_PRIV_H__ #define __UNITY_WEBAPPS_TOOLS_PRIV_H__ // T must be copy-constructible & have a default constructor template class Fallible { public: struct InvalidValueException {}; public: Fallible() : _valid(false) {} Fallible(const T& value, bool valid = true) : _valid(valid), _value(value) {} bool isvalid() const { return _valid; } T value() const { if (!_valid) throw InvalidValueException(); return _value; } private: bool _valid; T _value; }; #endif // __UNITY_WEBAPPS_TOOLS_PRIV_H__ ././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.hunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-p0000644000015301777760000000412112320722666033443 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #if !defined(__UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__) #define __UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__ // Qt #include #include #include class UnityWebappsAppModel; /*! * \brief The UnityWebappsAppModelFilterProxy class */ class UnityWebappsAppModelFilterProxy : public QSortFilterProxyModel { Q_OBJECT Q_PROPERTY(QString webappName READ webappName WRITE setwebappName NOTIFY webappNameChanged) Q_PROPERTY(UnityWebappsAppModel * sourceModel READ sourceModel WRITE setsourceModel NOTIFY sourceModelChanged) public: UnityWebappsAppModelFilterProxy(QObject *parent = 0); virtual ~UnityWebappsAppModelFilterProxy(); /*! * \brief webappName * \return */ QString webappName () const; /*! * \brief setwebappName * \param name */ void setwebappName (const QString& name); /*! * \brief sourceModel * \return */ UnityWebappsAppModel * sourceModel() const; /*! * \brief setSourceModel * \param model */ void setsourceModel(UnityWebappsAppModel * model); Q_SIGNALS: void webappNameChanged () const; void sourceModelChanged () const; protected: // From QSortFilterProxyModel::filterAcceptsRow bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; private: QString _name; }; #endif // __UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__ ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.cppunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parse0000644000015301777760000001221512320722666033544 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include #include #include #include "unity-webapps-app-manifest-parser.h" UnityWebappsAppManifestParser::UnityWebappsAppManifestParser(QObject *parent) :QObject(parent) {} UnityWebappsAppManifestParser::~UnityWebappsAppManifestParser() {} ManifestFileInfoOption UnityWebappsAppManifestParser::parse (QFileInfo manifest) { if (!manifest.isFile()) { qDebug() << "Invalid webapps path found: " << manifest.absoluteFilePath(); return ManifestFileInfoOption(); } QFile f(manifest.absoluteFilePath()); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Could not open manifest file: " << manifest.absoluteFilePath(); return ManifestFileInfoOption(); } QTextStream istream(&f); istream.setCodec("UTF-8"); QString content = istream.readAll(); ManifestFileInfo infos; if (!parseContent(content, &infos)) { qDebug() << "Could not open manifest file: " << manifest.absoluteFilePath(); return ManifestFileInfoOption(); } return ManifestFileInfoOption(infos); } bool UnityWebappsAppManifestParser::parseContent(const QString& content, ManifestFileInfo * infos) { if (! infos) return false; QJsonParseError error; QJsonDocument doc(QJsonDocument::fromJson(content.toStdString().c_str(), &error)); if (error.error != QJsonParseError::NoError) { qDebug() << "Could not parse json from manifest: " << error.errorString(); return false; } if (!doc.isObject()) return false; #define VALIDATE_PROPERTY_TYPE(property,predicate) \ !object.contains(QLatin1String(property)) \ || !object.value(QLatin1String(property)).predicate() QJsonObject object = doc.object(); if (VALIDATE_PROPERTY_TYPE("name",isString) || VALIDATE_PROPERTY_TYPE("domain",isString) || VALIDATE_PROPERTY_TYPE("homepage",isString) || VALIDATE_PROPERTY_TYPE("includes",isArray) || VALIDATE_PROPERTY_TYPE("requires",isArray) || VALIDATE_PROPERTY_TYPE("scripts",isArray) ) { return false; } #undef VALIDATE_PROPERTY_TYPE infos->domain = object.value(QLatin1String("domain")).toString(); infos->name = object.value(QLatin1String("name")).toString(); infos->homepage = object.value(QLatin1String("homepage")).toString(); infos->scripts = parseArray(object, QLatin1String("scripts")); infos->requires = parseArray(object, QLatin1String("requires")); infos->includes = parseArray(object, QLatin1String("includes")); QString chromeOption; if (object.contains("chrome") && object.value("chrome").isString()) { chromeOption = object.value("chrome").toString(); } infos->chromeOptions = parseChromeOptions(chromeOption); return true; } QStringList UnityWebappsAppManifestParser::parseChromeOptions(const QString& options) { static const QStringList DEFAULT_OPTIONS("no-chrome"); if (options.isNull() || options.isEmpty()) return DEFAULT_OPTIONS; static const QStringList VALID_CHROME_OPTIONS = (QStringList() << "no-chrome" << "back-forward-buttons" << "reload-button"); QStringList result; // strip unvalid options QStringList splittedOptions = options.split(";"); Q_FOREACH(QString option, splittedOptions) { if (VALID_CHROME_OPTIONS.contains(option.trimmed())) { result.append(option.trimmed()); } } // no-chrome has precedence if (result.contains("no-chrome")) { result.clear(); result.append("no-chrome"); } if (result.isEmpty()) { qDebug() << "Chrome display selection defaulting to no-chrome since no option was found"; result.append("no-chrome"); } return result; } QStringList UnityWebappsAppManifestParser::parseArray(const QJsonObject& parent , const QString& name) { QJsonValue value = parent.value(name); if (!value.isArray()) { //TODO shoudl be meaner than that qDebug() << "Was expecting an array for name " << name; return QStringList(); } QJsonArray array = value.toArray(); QStringList parsedArray; Q_FOREACH(QVariant v, array.toVariantList()) { if (!v.canConvert(QVariant::String)) continue; parsedArray.append(v.toString()); } return parsedArray; } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-messaging-menu.cppunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-messaging-menu0000644000015301777760000002052012320722666033534 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include #include #include #include #include #include #include #include "unity-webapps-desktop-infos.h" #include "unity-webapps-app-infos.h" #include "unity-webapps-icon-utils.h" #include "unity-webapps-api-messaging-menu.h" #define API_CALL_HEADER() do { \ d->init(); \ if (!d->_mmapp) \ return; \ } while(0) namespace { GIcon * requestImage(const QString &iconId) { QByteArray utf8Name = QUrl::fromPercentEncoding(iconId.toUtf8()).toUtf8(); GError *error = NULL; GIcon *icon = g_icon_new_for_string(utf8Name.data(), &error); if (error) { qDebug() << "Could not load icon: " << error->message; g_error_free(error); return NULL; } return icon; } } // namespace { static void unity_webapps_messaging_menu_source_activated ( MessagingMenuApp *mmapp, const gchar *source_id, gpointer user_data); struct UnityWebappsMessagingMenuPrivate { UnityWebappsMessagingMenuPrivate (UnityWebappsMessagingMenu * qq); ~UnityWebappsMessagingMenuPrivate (); void clear(); void init(); void sourceActivated(); UnityWebappsAppInfos *_appInfos; MessagingMenuApp *_mmapp; QStringList _sources; QObject* _callback; UnityWebappsMessagingMenu * const q_ptr; Q_DECLARE_PUBLIC(UnityWebappsMessagingMenu) }; UnityWebappsMessagingMenuPrivate::UnityWebappsMessagingMenuPrivate (UnityWebappsMessagingMenu * qq) : _appInfos(0), _mmapp(0), _callback(0), q_ptr(qq) { } UnityWebappsMessagingMenuPrivate::~UnityWebappsMessagingMenuPrivate() { clear(); } void UnityWebappsMessagingMenuPrivate::sourceActivated() { Q_Q(UnityWebappsMessagingMenu); Q_EMIT q->raised(); if (_callback) QMetaObject::invokeMethod(_callback, "trigger"); } void UnityWebappsMessagingMenuPrivate::clear() { if (_mmapp && G_IS_OBJECT(_mmapp)) { g_signal_handlers_disconnect_by_func(_mmapp, (gpointer)unity_webapps_messaging_menu_source_activated, this); g_object_unref(_mmapp); _mmapp = 0; } _appInfos = 0; _callback = 0; _sources.clear(); } static void unity_webapps_messaging_menu_source_activated ( MessagingMenuApp *mmapp, const gchar *source_id, gpointer user_data) { Q_UNUSED(mmapp); Q_UNUSED(source_id); UnityWebappsMessagingMenuPrivate* self = static_cast(user_data); // FIXME make sure that we have a proper qobject (still alive) // if ( ! qobject_cast(self)) // return; if (self) self->sourceActivated(); } void UnityWebappsMessagingMenuPrivate::init() { if (Q_UNLIKELY(_mmapp != NULL)) return; if (Q_UNLIKELY(_appInfos == NULL)) { qDebug() << "Trying to initialize the MessagingMenu binding with invalid context"; return; } QString desktopId = _appInfos->desktopId(); if (desktopId.isEmpty()) { qDebug() << "MessagingMenu backend: invalid desktop id (empty)"; return; } _mmapp = messaging_menu_app_new (desktopId.toUtf8().data()); messaging_menu_app_register (_mmapp); g_signal_connect (_mmapp, "activate-source", G_CALLBACK (unity_webapps_messaging_menu_source_activated), this); } UnityWebappsMessagingMenu::UnityWebappsMessagingMenu(QObject *parent) : QObject(parent), d_ptr(new UnityWebappsMessagingMenuPrivate(this)) {} UnityWebappsMessagingMenu::~UnityWebappsMessagingMenu() { delete d_ptr; } void UnityWebappsMessagingMenu::onAppInfosChanged(UnityWebappsAppInfos *appInfos) { Q_D(UnityWebappsMessagingMenu); bool wasInit = false; if (d->_mmapp) { wasInit = true; d->clear(); } d->_appInfos = appInfos; if (wasInit) d->init(); } void UnityWebappsMessagingMenu::showIndicator(const QString& indicatorName) { Q_D(UnityWebappsMessagingMenu); API_CALL_HEADER(); if (indicatorName.isEmpty()) { qDebug() << "Invalid indicator label name: " << indicatorName; return; } QByteArray content = indicatorName.toUtf8(); const gchar *indicatorName_cstr = content.data(); if ( ! messaging_menu_app_has_source (d->_mmapp, indicatorName_cstr)) { messaging_menu_app_append_source (d->_mmapp, indicatorName_cstr, NULL, indicatorName_cstr); d->_sources.append(indicatorName); } } void UnityWebappsMessagingMenu::clearIndicator(const QString& indicatorName) { Q_D(UnityWebappsMessagingMenu); API_CALL_HEADER(); QByteArray content = indicatorName.toUtf8(); const gchar *indicatorName_cstr = content.data(); if (messaging_menu_app_has_source (d->_mmapp, indicatorName_cstr)) { messaging_menu_app_remove_source (d->_mmapp, indicatorName_cstr); d->_sources.removeAll(indicatorName); } } void UnityWebappsMessagingMenu::clearIndicators() { Q_D(UnityWebappsMessagingMenu); API_CALL_HEADER(); QStringList indicators = d->_sources; Q_FOREACH(QString indicator, indicators) { clearIndicator(indicator); } } void UnityWebappsMessagingMenu::setProperty(const QString& indicatorName, const QString& propertyName, const QVariant& value) { Q_D(UnityWebappsMessagingMenu); API_CALL_HEADER(); if (indicatorName.isEmpty()) { qDebug() << "Invalid empty indicator name"; return; } if (propertyName.isEmpty()) { qDebug() << "Invalid empty indicator property"; return; } QByteArray content = indicatorName.toUtf8(); const gchar *indicatorName_cstr = content.data(); if (propertyName.compare("icon", Qt::CaseInsensitive) == 0) { GIcon *icon = requestImage(UnityWebappsQML::getIconPathFor(value.toString())); messaging_menu_app_set_source_icon (d->_mmapp, indicatorName_cstr, icon); g_object_unref (icon); } else if (propertyName.compare("callback", Qt::CaseInsensitive) == 0) { if (QString(value.typeName()).compare("QObject*") != 0) { qDebug() << "Invalid callback type"; return; } //FIXME: ownership & lifetime management QObject * const callback = *static_cast(value.data()); if (callback->metaObject()->indexOfSlot("trigger") != -1) { qDebug() << "Invalid callback type: no trigger method"; return; } d->_callback = callback; } else if (propertyName.compare("label", Qt::CaseInsensitive) == 0) { const char *label= value.toString().toStdString().c_str(); messaging_menu_app_set_source_label (d->_mmapp, indicatorName_cstr, label); } else if (propertyName.compare("count", Qt::CaseInsensitive) == 0) { int count = value.toString().toInt(); messaging_menu_app_set_source_count (d->_mmapp, indicatorName_cstr, count); if (count != 0) messaging_menu_app_draw_attention (d->_mmapp, indicatorName_cstr); else messaging_menu_app_remove_attention (d->_mmapp, indicatorName_cstr); } } void UnityWebappsMessagingMenu::classBegin() { } void UnityWebappsMessagingMenu::componentComplete() { } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/callback.h0000644000015301777760000000216112320722666027224 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_CALLBACK_H__ #define __UNITY_WEBAPPS_CALLBACK_H__ #include #include class UnityWebappsCallback : public QObject { Q_OBJECT public: UnityWebappsCallback(QObject *parent = 0); ~UnityWebappsCallback(); public Q_SLOTS: Q_INVOKABLE void trigger (QVariant user_data = QVariant()); Q_SIGNALS: void triggered(QVariant user_data = QVariant()); }; #endif // __UNITY_WEBAPPS_CALLBACK_H__ ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/application-signal-to-qt-bridge.cppunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/application-signal-to-qt-bridge.0000644000015301777760000000642712320722666033403 0ustar pbusernogroup00000000000000/* * Copyright 2014 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "application-signal-to-qt-bridge.h" #include #include #include #include #include /** * @brief The ApplicationSignalToQtBridgePrivate class * * It does the job described here: * * https://qt-project.org/doc/qt-5.0/qtdoc/unix-signals.html * * and bridges Unix signal handlers & qt objects in a proper * way. * */ class ApplicationSignalToQtBridgePrivate: public QObject { Q_OBJECT public: ApplicationSignalToQtBridgePrivate(QObject * parent) : QObject(parent), _signalSocketNotifier(NULL) {} ~ApplicationSignalToQtBridgePrivate() { delete _signalSocketNotifier; } QSocketNotifier * _signalSocketNotifier; }; int ApplicationSignalToQtBridge::signalSocketPair[2]; ApplicationSignalToQtBridge::ApplicationSignalToQtBridge(QObject *parent) : QObject(parent) , d_ptr(new ApplicationSignalToQtBridgePrivate(this)) {} ApplicationSignalToQtBridge::~ApplicationSignalToQtBridge() { delete d_ptr; } void ApplicationSignalToQtBridge::setupQtSignalListener() { Q_D(ApplicationSignalToQtBridge); if (0 != ::socketpair(AF_UNIX, SOCK_STREAM, 0, signalSocketPair)) { qFatal("Couldn't create HUP socketpair"); } d->_signalSocketNotifier = new QSocketNotifier (signalSocketPair[1], QSocketNotifier::Read, this); connect(d->_signalSocketNotifier, SIGNAL(activated(int)), this, SLOT(handleSignal(int))); } bool ApplicationSignalToQtBridge::addSignalHandlerFor(int type) { Q_D(ApplicationSignalToQtBridge); if ( ! d->_signalSocketNotifier) setupQtSignalListener(); struct sigaction sa; sa.sa_handler = ApplicationSignalToQtBridge::signalHandler; sigemptyset (&sa.sa_mask); sa.sa_flags = 0; sa.sa_flags |= SA_RESTART; return sigaction (type, &sa, 0) > 0; } void ApplicationSignalToQtBridge::signalHandler(int type) { if (0 != signalSocketPair[0]) { size_t size = ::write (signalSocketPair[0], &type, sizeof(type)); Q_UNUSED(size); } } void ApplicationSignalToQtBridge::handleSignal(int socket) { Q_D(ApplicationSignalToQtBridge); Q_UNUSED(socket); d->_signalSocketNotifier->setEnabled(false); int type = 0; size_t size = ::read (signalSocketPair[1], &type, sizeof(type)); Q_UNUSED(size); Q_EMIT onSignalRaised(type); d->_signalSocketNotifier->setEnabled(true); } #include "application-signal-to-qt-bridge.moc" unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-desktop-infos.cpp0000644000015301777760000000246112320722666033420 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include "unity-webapps-desktop-infos.h" QString UnityWebappsQML::buildDesktopInfoFileForWebapp (const QString& name, const QString& domain) { return QString("%1%2").arg(UnityWebappsQML::canonicalize(name)).arg(UnityWebappsQML::canonicalize(domain)); } QString UnityWebappsQML::canonicalize(const QString& s, bool keep_whitespaces) { QString canonicalized; for (QString::const_iterator it = s.begin(); it != s.end(); ++it) { if (it->isLetterOrNumber() || (keep_whitespaces && it->isSpace())) canonicalized.append(*it); } return canonicalized; } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/callback.cpp0000644000015301777760000000174112320722666027562 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "callback.h" #include #include #include UnityWebappsCallback::UnityWebappsCallback(QObject *parent) : QObject(parent) {} UnityWebappsCallback::~UnityWebappsCallback() {} void UnityWebappsCallback::trigger (QVariant user_data) { Q_EMIT triggered(user_data); } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp0000644000015301777760000003340312320722666032511 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include "unity-webapps-app-model.h" #include "unity-webapps-app-manifest-parser.h" /*! \qmltype UnityWebappsAppModel \inqmlmodule Ubuntu.UnityWebApps 0.1 \ingroup ubuntu \brief Provides a model for the list of the currently installed WebApps. Besides providing information about the currently installed webapps, it can typically be used in conjunction with the UnityWebApps QML component that already takes care of making sure that the Unity WebApps API is available to a given QML WebView. What the UnityWebappsAppModel can provide is a way to ask the WebApp QML component to inject the userscripts corresponding to a given webapp along with the API itself. \qml UnityWebApps { id: webapps name: webappName bindee: webview model: UnityWebappsAppModel {} } \endqml If the WebApp whose name is specified as part of the "name" property is found in the specified model, its scripts (along with their dependancies) will be injected. Otherwise only the API will be made available. The \l searchPath property can be use to alter the path where the model searches for installed webapps. The default search path is set to /usr/share/unity-webapps. The \l searchPath property should only be set to valid (existing and readable) paths, all other "values" are ignored. */ // TODO add local folders QString UnityWebappsAppModel::_commonScriptsDirName = "common"; QString UnityWebappsAppModel::_webappDirPrefix = "unity-webapps-"; QString UnityWebappsAppModel::doCorrectSearchPath(const QString & p) { QString fixedPath = p; if (QDir::isRelativePath(fixedPath)) { QDir d(fixedPath); d.makeAbsolute(); fixedPath = d.absolutePath(); } return fixedPath; } QString UnityWebappsAppModel::getDefaultWebappsInstallationSearchPath() { return "/usr/share/unity-webapps/userscripts"; } UnityWebappsAppModel::UnityWebappsAppModel(QObject* parent) : QAbstractListModel(parent) , _searchPath(getDefaultWebappsInstallationSearchPath()) , _doSearchLocalHome(false) { load(); QObject::connect(this, SIGNAL(searchPathChanged(const QString)), SLOT(load())); } UnityWebappsAppModel::~UnityWebappsAppModel() {} QString UnityWebappsAppModel::searchPath() const { return _searchPath; } bool UnityWebappsAppModel::doSearchHomeFolder() const { return _doSearchLocalHome; } void UnityWebappsAppModel::setDoSearchHomeFolder (bool searchLocalHome) { bool reload = (searchLocalHome != _doSearchLocalHome); _doSearchLocalHome = searchLocalHome; if (reload) load(); } void UnityWebappsAppModel::setSearchPath(const QString& path) { if (_searchPath.compare(path, Qt::CaseInsensitive) == 0) return; if (path.isEmpty()) { qDebug() << "Empty path in webapps model search path update request"; return; } QDir searchDir(path); searchDir.makeAbsolute(); if (! searchDir.exists() || ! searchDir.isReadable()) { qDebug() << "Invalid path in webapps " "model search path update request: " << path; return; } _searchPath = doCorrectSearchPath(searchDir.path()); qDebug() << "Using '" << _searchPath << "' as the default search path for installed webapps"; Q_EMIT searchPathChanged(_searchPath); } QHash UnityWebappsAppModel::roleNames() const { static QHash roles; if (roles.isEmpty()) { roles[Name] = "name"; roles[Domain] = "domain"; roles[Homepage] = "homepage"; roles[Urls] = "urls"; roles[ScriptsContent] = "content"; roles[Scripts] = "scripts"; } return roles; } UnityWebappsAppModel::WebappFileInfoOption UnityWebappsAppModel::getWebappFiles(QFileInfo webAppInstallLocation) { if (!webAppInstallLocation.isDir()) { qDebug() << "Invalid webapps path found (not a proper folder): " << webAppInstallLocation.absoluteFilePath(); return WebappFileInfoOption(); } QDir installationDir = QDir(webAppInstallLocation.absoluteFilePath()); //TODO search only for manifest.json // Search for manifest & userscript QFileInfoList manifest = installationDir.entryInfoList(QStringList("*.json"), QDir::Files); if (manifest.count() != 1) { qDebug() << "Folder not being considered for webapp (no manifest file found): " << installationDir.absolutePath(); return WebappFileInfoOption(); } QFileInfoList script = installationDir.entryInfoList(QStringList("*.user.js"), QDir::Files); if (script.count() != 1) { qDebug() << "Folder not being considered for webapp (no userscript found): " << installationDir.absolutePath(); return WebappFileInfoOption(); } return WebappFileInfoOption (WebappFileInfo (manifest[0].absoluteFilePath(), script[0].absoluteFilePath())); } QFileInfoList UnityWebappsAppModel::getCandidateInstalledWebappsFolders (const QString& installationSearchPath) { QDir webappsDir(installationSearchPath); return webappsDir.entryInfoList (QStringList(_webappDirPrefix + "*"), QDir::Dirs); } void UnityWebappsAppModel::cleanup() { _webapps.clear(); } void UnityWebappsAppModel::load() { cleanup(); QString installationSearchPath = searchPath(); if (!isValidInstall(installationSearchPath)) { qDebug() << "Invalid webapps installation"; return; } QFileInfoList folders = getCandidateInstalledWebappsFolders (installationSearchPath); Q_FOREACH(QFileInfo candidateWebappFolder, folders) { if (!candidateWebappFolder.isDir()) { qDebug() << "Candidate webapp folder not a webapp: " << candidateWebappFolder.absoluteFilePath(); continue; } WebappFileInfoOption webappInfos = getWebappFiles (candidateWebappFolder); if (!webappInfos.isvalid()) { qDebug() << "Invalid webapps path found: " << candidateWebappFolder.absoluteFilePath(); continue; } UnityWebappsAppManifestParser parser; ManifestFileInfoOption manifest = parser.parse (QFileInfo (webappInfos.value().manifestFilename)); if (!manifest.isvalid()) { qDebug() << "Invalid webapps installation found: " << candidateWebappFolder.absoluteFilePath(); continue; } // FIXME: mmmh? ondemand or async? QString content = loadUserScript (QDir(candidateWebappFolder.absoluteFilePath()), manifest.value()); const QString COMMON_BASE_PATH = _searchPath + QDir::separator() + _commonScriptsDirName; //TODO: find proper common files (if any) considering the ones // in local/ that could over take addWebApp (candidateWebappFolder.absoluteFilePath(), COMMON_BASE_PATH, manifest.value(), content); } Q_EMIT modelChanged(); } QString UnityWebappsAppModel::loadUserScript(const QDir& userscriptPath, const ManifestFileInfo& manifest) { if (manifest.scripts.count() == 0) { return QString(); } //TODO: use QStringBuilder QString script; #define READ_USER_SCRIPT(field_name,base_path) \ Q_FOREACH(QString filename, manifest.field_name) \ { \ QFile f(base_path + QDir::separator() + filename); \ if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) \ { \ return QString(); \ } \ script += f.readAll(); \ script += "\n\n"; \ } QString installationSearchPath = _searchPath; const QString COMMON_BASE_PATH = installationSearchPath + QDir::separator() + _commonScriptsDirName; READ_USER_SCRIPT(requires,COMMON_BASE_PATH); READ_USER_SCRIPT(scripts,userscriptPath.absolutePath()); return script; } QStringList UnityWebappsAppModel::getChromeOptionsFor(const QString & webappName) const { if (!exists(webappName)) return QStringList(); int idx = getWebappIndex(webappName); if (Q_UNLIKELY(idx == -1)) { qDebug() << "Invalid index for a supposedly existing webapp: " << webappName; return QStringList(); } return data(idx, Chrome).toStringList(); } QString UnityWebappsAppModel::getDomainFor(const QString & webappName) const { //FIXME: very inefficient if (!exists(webappName)) return QString(); int idx = getWebappIndex(webappName); if (Q_UNLIKELY(idx == -1)) { qDebug() << "Invalid index for a supposedly existing webapp: " << webappName; return QString(); } return data(idx, Domain).toString(); } bool UnityWebappsAppModel::doesUrlMatchesWebapp(const QString & webappName, const QString & url) const { if (!exists(webappName)) return false; int idx = getWebappIndex(webappName); if (Q_UNLIKELY(idx == -1)) { qDebug() << "Invalid index for a supposedly existing webapp: " << webappName; return false; } // TODO: very very inefficient QStringList urls = data(idx, Urls).toStringList(); bool matches = false; Q_FOREACH(const QString& urlCandidate, urls) { QRegExp pattern(urlCandidate, Qt::CaseInsensitive, QRegExp::Wildcard); if (pattern.indexIn(url) != -1) { matches = true; break; } } return matches; } QString UnityWebappsAppModel::getDisplayNameFor(const QString & webappName) const { //FIXME: very inefficient if (!exists(webappName)) return QString(); int idx = getWebappIndex(webappName); if (Q_UNLIKELY(idx == -1)) { qDebug() << "Invalid index for a supposedly existing webapp: " << webappName; return QString(); } return data(idx, Name).toString(); } void UnityWebappsAppModel::addWebApp(const QString& userscriptLocation, const QString& requiresLocation, const ManifestFileInfo& manifest, const QString& content) { if (manifest.name.isEmpty()) { qDebug() << "Cannot add a webapp with an empty name"; return; } /* if (_webapps.contains(manifest)) { qDebug() << "Webapp already exists: " << manifest.name; return; } */ InstalledWebApp webapp; webapp.userscriptLocation = userscriptLocation; webapp.requiresLocation = requiresLocation; webapp.data.manifest = manifest; webapp.data.content = content; _webapps.append(webapp); } bool UnityWebappsAppModel::isValidInstall(const QString& searchPath) { return QFileInfo(searchPath).isDir() && QDir(searchPath).exists() && QFileInfo(searchPath + QDir::separator() + _commonScriptsDirName).isDir() && QDir(searchPath + QDir::separator() + _commonScriptsDirName).exists(); } int UnityWebappsAppModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); return _webapps.count(); } int UnityWebappsAppModel::getWebappIndex(const QString & webappName) const { if (_webapps.empty()) return -1; int idx = 0; for (QList::const_iterator it = _webapps.begin() ; it != _webapps.end() ; ++idx, ++it) { if (0 == it->data.manifest.name.toLower().compare(webappName.toLower())) { return idx; } } return -1; } bool UnityWebappsAppModel::exists(const QString & webappName) const { //FIXME: efficiency return getWebappIndex(webappName) != -1; } QVariant UnityWebappsAppModel::data(int row, int role) const { if ((row < 0) || (row >= _webapps.count())) { qDebug() << "UnityWebappsAppModel::data: Invalid index (out of bound)"; return QVariant(); } const InstalledWebApp& webapp = _webapps.at(row); switch (role) { case Name: return webapp.data.manifest.name; case Domain: return webapp.data.manifest.domain; case Homepage: return webapp.data.manifest.homepage; case Urls: return webapp.data.manifest.includes; case Chrome: return webapp.data.manifest.chromeOptions; case Scripts: { QStringList scripts; Q_FOREACH(QString require, webapp.data.manifest.requires) { scripts.append(webapp.requiresLocation + "/" + require); } Q_FOREACH(QString script, webapp.data.manifest.scripts) { scripts.append(webapp.userscriptLocation + "/" + script); } return scripts; } case ScriptsContent: return webapp.data.content; } return QVariant(); } QVariant UnityWebappsAppModel::data(const QModelIndex& index, int role) const { if ( ! index.isValid()) { return QVariant(); } return data(index.row(), role); } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/abstract-item-model-adaptor.cpp0000644000015301777760000000654212320722666033317 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include "abstract-item-model-adaptor.h" class AbstractItemModelAdaptorPrivate: public QObject { Q_OBJECT public: AbstractItemModelAdaptorPrivate(QObject * parent) : QObject(parent), _model(NULL) {} QAbstractItemModel * _model; }; AbstractItemModelAdaptor::AbstractItemModelAdaptor(QObject *parent) : QObject(parent), d_ptr(new AbstractItemModelAdaptorPrivate(this)) {} AbstractItemModelAdaptor::~AbstractItemModelAdaptor() { delete d_ptr; } QVariant AbstractItemModelAdaptor::itemAt(int index , const QString & role) { Q_D(AbstractItemModelAdaptor); if ( ! d->_model) return QVariant(); int roleIdx = roleIndexFromName(role); if (roleIdx < 0) return QVariant(); return (d->_model == NULL || !d->_model->hasIndex(index, 0)) ? QVariant() : d->_model->data(d->_model->index(index, 0), roleIdx); } int AbstractItemModelAdaptor::roleIndexFromName(const QString & name) { Q_D(AbstractItemModelAdaptor); int index = -1; if ( ! d->_model) return index; QHash roleNames = d->_model->roleNames(); for(QHash::iterator it = roleNames.begin(); it != roleNames.end(); ++it) { if (name.compare(QString(it.value())) == 0) { index = it.key(); break; } } return index; } QStringList AbstractItemModelAdaptor::roles() { Q_D(AbstractItemModelAdaptor); QStringList currentRoles; if ( ! d->_model) return currentRoles; QHash roleNames = d->_model->roleNames(); for(QHash::iterator it = roleNames.begin(); it != roleNames.end(); ++it) { currentRoles.append(QString(it.value())); } return currentRoles; } QObject * AbstractItemModelAdaptor::itemModel() { Q_D(AbstractItemModelAdaptor); return d->_model; } int AbstractItemModelAdaptor::rowCount() { Q_D(AbstractItemModelAdaptor); if ( ! d->_model) return -1; return d->_model->rowCount(); } void AbstractItemModelAdaptor::setItemModel(QObject * model) { Q_D(AbstractItemModelAdaptor); if ( ! qobject_cast(model)) { qCritical() << "Cannot assign a QObject of " "type not QAbstractItemModel to itemModel"; return; } QAbstractItemModel * abstractItemModel = qobject_cast(model); if (abstractItemModel == d->_model) return; d->_model = abstractItemModel; Q_EMIT itemModelChanged(); } #include "abstract-item-model-adaptor.moc" unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-launcher.cpp0000644000015301777760000001072612320722666033206 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include #include #include #include #include #include #include #include "unity-webapps-desktop-infos.h" #include "unity-webapps-app-infos.h" #include "unity-webapps-api-launcher.h" #define API_CALL_HEADER() do { \ d->init(); \ if (!d->_launcher) \ return; \ } while(0) namespace { } // namespace { struct UnityWebappsLauncherPrivate { UnityWebappsLauncherPrivate(); ~UnityWebappsLauncherPrivate(); void clear(); void init(); UnityWebappsAppInfos *_appInfos; UnityLauncherEntry *_launcher; QObject* _callback; }; UnityWebappsLauncherPrivate::UnityWebappsLauncherPrivate() :_appInfos(0), _launcher(0), _callback(0) { } UnityWebappsLauncherPrivate::~UnityWebappsLauncherPrivate() { clear(); } void UnityWebappsLauncherPrivate::clear() { if (_launcher && G_IS_OBJECT(_launcher)) { g_object_unref (G_OBJECT (_launcher)); _launcher = 0; } _appInfos = 0; _callback = 0; } void UnityWebappsLauncherPrivate::init() { if (Q_UNLIKELY(_launcher != NULL)) return; if (Q_UNLIKELY(_appInfos == NULL)) { qDebug() << "Trying to initialize the Launcher binding with invalid context"; return; } QString desktopId = _appInfos->desktopId(); if (desktopId.isEmpty()) { qDebug() << "MessagingMenu: invalid desktop id (empty)"; return; } _launcher = unity_launcher_entry_get_for_desktop_id (desktopId.toUtf8().data()); } UnityWebappsLauncher::UnityWebappsLauncher(QObject *parent) : QObject(parent), d_ptr(new UnityWebappsLauncherPrivate()) {} UnityWebappsLauncher::~UnityWebappsLauncher() { delete d_ptr; } void UnityWebappsLauncher::onAppInfosChanged(UnityWebappsAppInfos *appInfos) { Q_D(UnityWebappsLauncher); bool wasInit = false; if (d->_launcher) { wasInit = true; d->clear(); } d->_appInfos = appInfos; if (wasInit) d->init(); } void UnityWebappsLauncher::setCount(int count) { Q_D(UnityWebappsLauncher); API_CALL_HEADER(); unity_launcher_entry_set_count (d->_launcher, count); unity_launcher_entry_set_count_visible (d->_launcher, TRUE); } int UnityWebappsLauncher::getCount() { Q_D(UnityWebappsLauncher); d->init(); if (!d->_launcher) return 0; return unity_launcher_entry_get_count(d->_launcher); } void UnityWebappsLauncher::clearCount() { Q_D(UnityWebappsLauncher); API_CALL_HEADER(); unity_launcher_entry_set_count_visible (d->_launcher, FALSE); } void UnityWebappsLauncher::setProgress(double progress) { Q_D(UnityWebappsLauncher); API_CALL_HEADER(); unity_launcher_entry_set_progress (d->_launcher, progress); unity_launcher_entry_set_progress_visible (d->_launcher, TRUE); } double UnityWebappsLauncher::getProgress() { Q_D(UnityWebappsLauncher); d->init(); if (!d->_launcher) return 0; return unity_launcher_entry_get_progress (d->_launcher); } void UnityWebappsLauncher::clearProgress() { Q_D(UnityWebappsLauncher); API_CALL_HEADER(); unity_launcher_entry_set_progress_visible (d->_launcher, FALSE); } void UnityWebappsLauncher::setUrgent() { Q_D(UnityWebappsLauncher); API_CALL_HEADER(); unity_launcher_entry_set_urgent (d->_launcher, TRUE); } void UnityWebappsLauncher::addAction(const QString & actionName, const QString & action) { Q_UNUSED(actionName); Q_UNUSED(action); } void UnityWebappsLauncher::removeAction(const QString & actionName) { Q_UNUSED(actionName); } void UnityWebappsLauncher::removeActions() { } void UnityWebappsLauncher::classBegin() { } void UnityWebappsLauncher::componentComplete() { } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.h0000644000015301777760000000470512320722666032177 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_APP_INFOS_H__ #define __UNITY_WEBAPPS_APP_INFOS_H__ #include #include class UnityWebappsAppModel; class UnityWebappsAppInfos : public QObject { Q_OBJECT Q_PROPERTY(QString appName READ appName WRITE setAppName NOTIFY appNameChanged) Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged) Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged) Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) Q_PROPERTY(QString desktopId READ desktopId WRITE setDesktopId NOTIFY desktopIdChanged) Q_PROPERTY(UnityWebappsAppModel* model READ model WRITE setModel NOTIFY modelChanged) public: UnityWebappsAppInfos(QObject *parent = 0); ~UnityWebappsAppInfos(); void setAppName(const QString& name); QString appName() const; void setDisplayName(const QString& name); QString displayName() const; void setDomain(const QString& domain); QString domain() const; void setIconName(const QString& name); QString iconName() const; void setDesktopId(const QString& desktopId); QString desktopId() const; UnityWebappsAppModel* model() const; void setModel(UnityWebappsAppModel *); Q_SIGNALS: void appNameChanged(const QString& name); void desktopIdChanged(const QString& desktopId); void displayNameChanged(const QString& displayName); void iconNameChanged(const QString& iconName); void domainChanged(const QString& domain); void modelChanged(UnityWebappsAppModel * model); private: QString _appName; QString _iconName; QString _displayName; QString _desktopId; QString _domain; UnityWebappsAppModel * _model; }; #endif // __UNITY_WEBAPPS_APP_INFOS_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api.h0000644000015301777760000001152612320722666031053 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_API_H__ #define __UNITY_WEBAPPS_API_H__ #include #include #include #include #include "callback.h" class UnityWebappsAppInfos; class UnityWebappsAppModel; class UnityWebapps : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(UnityWebappsAppModel* model READ model WRITE setAppModel) Q_PROPERTY(bool handleDesktopFileUpdates READ handleDesktopFileUpdates WRITE setHandleDesktopFileUpdates) Q_PROPERTY(UnityWebappsAppInfos* appInfos READ appInfos NOTIFY appInfosChanged) public: UnityWebapps(QObject *parent = 0); ~UnityWebapps(); UnityWebappsAppModel* model() const; void setAppModel(UnityWebappsAppModel *); bool handleDesktopFileUpdates() const; void setHandleDesktopFileUpdates (bool); // TODO: really need it? void componentComplete(); void classBegin(); Q_INVOKABLE QString addIndicatorAction (const QString& name); Q_INVOKABLE QString addStaticAction (const QString& name, const QString& url); Q_INVOKABLE QString addLauncherAction (const QString& name); Q_INVOKABLE void removeLauncherAction (const QString& name); Q_INVOKABLE void removeLauncherActions (); public Q_SLOTS: // API functions void init(const QString& name, const QString& url, bool isLocal, const QVariant& args); // class functions UnityWebappsAppInfos *appInfos(); QString getDesktopFileContent(); Q_SIGNALS: void initCompleted(bool success); void appInfosChanged(UnityWebappsAppInfos *appInfos); private: enum ActionTypeFlags { STATIC_ACTION = 0x1, INDICATOR_ACTION = 0x2, LAUNCHER_ACTION = 0x4, }; QStringList collectActionNames() const; QString getUrlLaunchExec (const QString & webappName, const QString & url); QString addAction (const QString& name, ActionTypeFlags type, const QString & url = QString()); void removeAction (const QString& name); void ensureLocalApplicationsPathExists(); QString getLocalDesktopFilepath(const QString & desktopId); void updateDesktopFileContent(); QString extractFromGlobalDesktopFile(const QString & desktopFilename); QString generateActionEntryFor(const QString& actionName, const QString & webappName, const QString& showIn, const QString& exec); QString generateActionsEntry(const QString & webappName); bool isValidInitForWebappAndModel (const QString & name, const QString& domain, const QString & displayName); bool initInternal(const QString& name, const QString& domain, const QString& displayName, const QString& iconUrl, const QString& url); void cleanup(); bool isConfined() const; void buildAppInfos(const QString & name, const QString & displayName, const QString & domain, const QString & desktopId, const QString & iconName); bool createLocalDesktopFileFor (const QString& desktopId, const QString& webappName, const QString& domain, const QString& iconName); static QString getUserSharePath(); private: struct ActionInfos { ActionInfos() {} ActionInfos(const QString & n, size_t t, size_t i, const QString & u = QString()) : name(n), type(t), url(u), idx(i) {} QString name; size_t type; QString url; size_t idx; }; QMap collectActionIndexes(); int findNextAvailableActionIndex(const QMap & indexes); QMap _actions; UnityWebappsAppModel *_model; UnityWebappsAppInfos *_appInfos; bool _handleDesktopFileUpdates; static const QString WEBAPPS_RUNNER_EXEC; }; #endif // __UNITY_WEBAPPS_API_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h0000644000015301777760000001254412320722666032161 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #if !defined(__UNITY_WEBAPPS_APP_MODEL_H__) #define __UNITY_WEBAPPS_APP_MODEL_H__ // Qt #include #include #include #include #include #include "unity-webapps-app-manifest-parser.h" /*! * \brief Model for the currently installed WebApps * Each installed webapp can be pulled from this model. * * TODO: No "installation" monitor is currently being setup ... * TODO: make sure that we are properly initialized w/ QML (QMLParserStatus) */ class UnityWebappsAppModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(QString searchPath READ searchPath WRITE setSearchPath NOTIFY searchPathChanged) Q_PROPERTY(bool doSearchHomeFolder READ doSearchHomeFolder WRITE setDoSearchHomeFolder) Q_ENUMS(WebAppsRoles) public: UnityWebappsAppModel(QObject* parent = 0); ~UnityWebappsAppModel(); enum WebAppsRoles { Name = Qt::UserRole + 1, Domain, Urls, Homepage, Scripts, ScriptsContent, Chrome }; // QAbstractListModel implementation QHash roleNames() const; int rowCount(const QModelIndex& parent = QModelIndex ()) const; QVariant data(const QModelIndex& index, int role) const; // Properties QString searchPath() const; void setSearchPath (const QString& path); bool doSearchHomeFolder() const; void setDoSearchHomeFolder (bool searchLocalHome); // Exposed to QML /*! * \brief exists * \param webappName * \return */ Q_INVOKABLE bool exists(const QString & webappName) const; /*! * \brief getWebappIndex * \param webappName * \return */ Q_INVOKABLE int getWebappIndex(const QString & webappName) const; /*! * \brief */ Q_INVOKABLE QString getDomainFor(const QString & webappName) const; /*! * \brief */ Q_INVOKABLE QStringList getChromeOptionsFor(const QString & webappName) const; /*! * \brief */ Q_INVOKABLE bool doesUrlMatchesWebapp(const QString & webappName, const QString & url) const; /*! * \brief */ Q_INVOKABLE QString getDisplayNameFor(const QString & webappName) const; /*! * \brief data * \return */ Q_INVOKABLE QVariant data(int row, int role) const; Q_SIGNALS: void searchPathChanged(const QString & path); void modelChanged(); private Q_SLOTS: /*! * \brief Starts loading all the WebApps */ void load(); private: /*! * \brief Agreggates simple set of data on a given candidate for a WebApp install */ struct WebappFileInfo { WebappFileInfo () {} WebappFileInfo(const QString& m, const QString& s) : manifestFilename(m), userscript(s) {} QString manifestFilename; QString userscript; }; /*! * \brief Option type for WebappFileInfo */ typedef Fallible WebappFileInfoOption; /*! * \brief getWebappFiles * \param webappDir * \return */ WebappFileInfoOption getWebappFiles (QFileInfo webappDir); /*! * \brief UnityWebappsAppModel::getCandidateInstalledWebappsFolders * \return */ static QFileInfoList getCandidateInstalledWebappsFolders (const QString& installationSearchPath); static QString getDefaultWebappsInstallationSearchPath(); static QString doCorrectSearchPath(const QString & p); /*! * \brief Cleanup the object and already loaded WebApps */ void cleanup(); /*! * \brief addWebApp * \param userscriptLocation * \param requiresLocation * \param manifest * \param content */ void addWebApp(const QString& userscriptLocation, const QString& requiresLocation, const ManifestFileInfo& manifest, const QString& content); /*! * \brief isValidInstall * \param searchpath * \return */ bool isValidInstall(const QString& searchpath); /*! * \brief loadUserScript * \param path * \param manifest * \return */ QString loadUserScript(const QDir& path, const ManifestFileInfo& manifest); private: struct InstalledWebApp { QString userscriptLocation; QString requiresLocation; struct { ManifestFileInfo manifest; QString content; } data; }; QList _webapps; QString _searchPath; bool _doSearchLocalHome; static QString _commonScriptsDirName; static QString _webappDirPrefix; }; #endif // __UNITY_WEBAPPS_APP_MODEL_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-desktop-infos.h0000644000015301777760000000175112320722666033066 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_DESKTOP_INFOS_H__ #define __UNITY_WEBAPPS_DESKTOP_INFOS_H__ namespace UnityWebappsQML { QString buildDesktopInfoFileForWebapp (const QString& name, const QString& domain); QString canonicalize(const QString& s, bool keep_whitespaces = false); } #endif // __UNITY_WEBAPPS_DESKTOP_INFOS_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-launcher.h0000644000015301777760000000376412320722666032657 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_LAUNCHER_H__ #define __UNITY_WEBAPPS_LAUNCHER_H__ #include #include #include "unity-webapps-app-model.h" #include "unity-webapps-app-infos.h" class UnityWebappsLauncherPrivate; class UnityWebappsLauncher: public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) public: UnityWebappsLauncher(QObject * parent = 0); virtual ~UnityWebappsLauncher(); // API functions Q_INVOKABLE void setCount(int count); Q_INVOKABLE int getCount(); Q_INVOKABLE void clearCount(); Q_INVOKABLE void setProgress(double progress); Q_INVOKABLE double getProgress(); Q_INVOKABLE void clearProgress(); Q_INVOKABLE void setUrgent(); Q_INVOKABLE void addAction(const QString & actionName, const QString & action); Q_INVOKABLE void removeAction(const QString & actionName); Q_INVOKABLE void removeActions(); // Class functions void classBegin(); void componentComplete(); public Q_SLOTS: void onAppInfosChanged(UnityWebappsAppInfos *appInfos); Q_SIGNALS: void onActionAdded(const QString& name, const QString& action); void onActionRemoved(const QString& name); private: UnityWebappsLauncherPrivate *d_ptr; Q_DECLARE_PRIVATE(UnityWebappsLauncher) }; #endif // __UNITY_WEBAPPS_LAUNCHER_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/application-api.h0000644000015301777760000000411412320722666030542 0ustar pbusernogroup00000000000000/* * Copyright 2014 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef UNITY_WEBAPPS_APPLICATIONAPI_H #define UNITY_WEBAPPS_APPLICATIONAPI_H #include class ApplicationApiPrivate; class ApplicationApi : public QObject { Q_OBJECT Q_PROPERTY(QString applicationName READ getApplicationName NOTIFY applicationNameChanged) Q_PROPERTY(QString screenOrientation READ getApplicationScreenOrientation NOTIFY applicationScreenOrientationChanged) Q_PROPERTY(QString applicationDataPath READ getApplicationDataPath) Q_PROPERTY(QString applicationPlatform READ getApplicationPlatform) public: explicit ApplicationApi(QObject *parent = 0); ~ApplicationApi(); QString getApplicationName() const; QString getApplicationDataPath() const; QString getApplicationPlatform() const; QString getApplicationScreenOrientation() const; Q_INVOKABLE QString getInputMethodName() const; Q_INVOKABLE void setInputMethodVisible(bool); Q_SIGNALS: void applicationNameChanged(); void applicationAboutToQuit(bool killed); void applicationDeactivated(); void applicationActivated(); void applicationScreenOrientationChanged(QString); public Q_SLOTS: void aboutToQuit(); void deactivated(); void activated(); void screenOrientationChanged(Qt::ScreenOrientation); void signalReceived(int type); private: ApplicationApiPrivate *d_ptr; Q_DECLARE_PRIVATE(ApplicationApi) }; #endif // UNITY_WEBAPPS_APPLICATIONAPI_H ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-messaging-menu.hunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-messaging-menu0000644000015301777760000000366512320722666033547 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_MESSAGING_MENU_H__ #define __UNITY_WEBAPPS_MESSAGING_MENU_H__ #include #include #include "unity-webapps-app-infos.h" class UnityWebappsMessagingMenuPrivate; class UnityWebappsMessagingMenu: public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) public: UnityWebappsMessagingMenu(QObject * parent = 0); virtual ~UnityWebappsMessagingMenu(); // Supported WebApps APIs Q_INVOKABLE void showIndicator(const QString& indicatorName); Q_INVOKABLE void setProperty(const QString& indicatorName, const QString& propertyName, const QVariant& value); Q_INVOKABLE void clearIndicator(const QString& indicatorName); Q_INVOKABLE void clearIndicators(); // Class functions void classBegin(); void componentComplete(); public Q_SLOTS: void onAppInfosChanged(UnityWebappsAppInfos *appInfos); Q_SIGNALS: void raised(); void onActionAdded(const QString& name, const QString& action); void onActionRemoved(const QString& name); private: UnityWebappsMessagingMenuPrivate *d_ptr; Q_DECLARE_PRIVATE(UnityWebappsMessagingMenu) }; #endif // __UNITY_WEBAPPS_MESSAGING_MENU_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp0000644000015301777760000000464112320722666032531 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "unity-webapps-app-model.h" #include #include #include #include #include #include "unity-webapps-app-infos.h" UnityWebappsAppInfos::UnityWebappsAppInfos(QObject *parent) : QObject(parent) {} UnityWebappsAppInfos::~UnityWebappsAppInfos() {} void UnityWebappsAppInfos::setAppName(const QString& name) { if (_appName == name) return; _appName = name; Q_EMIT appNameChanged(name); } QString UnityWebappsAppInfos::appName() const { return _appName; } void UnityWebappsAppInfos::setDisplayName(const QString& name) { if (_displayName == name) return; _displayName = name; Q_EMIT displayNameChanged(name); } QString UnityWebappsAppInfos::displayName() const { return _displayName; } void UnityWebappsAppInfos::setDomain(const QString& domain) { if (_domain == domain) return; _domain = domain; Q_EMIT domainChanged(domain); } QString UnityWebappsAppInfos::domain() const { return _domain; } void UnityWebappsAppInfos::setDesktopId(const QString& desktopId) { if (_desktopId == desktopId) return; _desktopId = desktopId; Q_EMIT desktopIdChanged(desktopId); } QString UnityWebappsAppInfos::desktopId() const { return _desktopId; } void UnityWebappsAppInfos::setIconName(const QString& name) { if (_iconName == name) return; _iconName = name; Q_EMIT iconNameChanged(name); } QString UnityWebappsAppInfos::iconName() const { return _iconName; } UnityWebappsAppModel* UnityWebappsAppInfos::model() const { return _model; } void UnityWebappsAppInfos::setModel(UnityWebappsAppModel * model) { if (model == _model) return; _model = model; Q_EMIT modelChanged(model); } ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/application-signal-to-qt-bridge.hunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/application-signal-to-qt-bridge.0000644000015301777760000000263712320722666033402 0ustar pbusernogroup00000000000000/* * Copyright 2014 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef APPLICATIONSIGNALTOQTBRIDGE_H #define APPLICATIONSIGNALTOQTBRIDGE_H #include class ApplicationSignalToQtBridgePrivate; class ApplicationSignalToQtBridge : public QObject { Q_OBJECT public: explicit ApplicationSignalToQtBridge (QObject *parent = 0); ~ApplicationSignalToQtBridge (); bool addSignalHandlerFor(int type); public Q_SLOTS: void handleSignal(int type); Q_SIGNALS: void onSignalRaised(int type); private: void setupQtSignalListener(); // Unix signal handlers. static void signalHandler(int type); static int signalSocketPair[2]; ApplicationSignalToQtBridgePrivate *d_ptr; Q_DECLARE_PRIVATE(ApplicationSignalToQtBridge) }; #endif // APPLICATIONSIGNALTOQTBRIDGE_H ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-notifications.hunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-notifications.0000644000015301777760000000314412320722666033547 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_NOTIFICATIONS_H__ #define __UNITY_WEBAPPS_NOTIFICATIONS_H__ #include #include /*! * \brief The UnityWebappsNotification class */ class UnityWebappsNotification : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QString name READ name WRITE setName) public: explicit UnityWebappsNotification(QObject *parent = 0); virtual ~UnityWebappsNotification(); /*! * \brief setName * \param name */ void setName(const QString& name); /*! * \brief name * \return */ QString name() const; // TODO: don't really need it? void classBegin(); void componentComplete(); public Q_SLOTS: void show(const QString& summary, const QString& body, const QString& icon); private: QString _applicationName; }; #endif // __UNITY_WEBAPPS_NOTIFICATIONS_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/application-api.cpp0000644000015301777760000001637612320722666031112 0ustar pbusernogroup00000000000000/* * Copyright 2014 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "application-api.h" #include "application-signal-to-qt-bridge.h" #include #include #include #include #include #include #include namespace { QString nameFromScreenOrientation (Qt::ScreenOrientation orientation) { switch (orientation) { case Qt::InvertedLandscapeOrientation: return QString("InvertedLandscape"); case Qt::LandscapeOrientation: return QString("Landscape"); case Qt::PortraitOrientation: return QString("Portrait"); case Qt::InvertedPortraitOrientation: return QString("InvertedPortrait"); case Qt::PrimaryOrientation: return QString("Primary"); default: break; } return QString("Unknown"); } } class ApplicationApiEventListener : public QObject { Q_OBJECT public: ApplicationApiEventListener(QObject * parent) : QObject(parent) { if (QGuiApplication::instance()) QGuiApplication::instance()->installEventFilter(this); } ~ApplicationApiEventListener() { if (QGuiApplication::instance()) QGuiApplication::instance()->removeEventFilter(this); } bool eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { case QEvent::ApplicationActivate: Q_EMIT activated(); break; case QEvent::ApplicationDeactivate: Q_EMIT deactivated(); break; default: break; } return QObject::eventFilter(obj, event); } Q_SIGNALS: void activated(); void deactivated(); }; class ApplicationApiPrivate: public QObject { Q_OBJECT public: ApplicationApiPrivate(QObject * parent) : QObject(parent), _applicationEventListener(new ApplicationApiEventListener(this)), _applicationSignalBridge(new ApplicationSignalToQtBridge(this)) {} ~ApplicationApiPrivate() { delete _applicationEventListener; delete _applicationSignalBridge; } ApplicationApiEventListener * _applicationEventListener; ApplicationSignalToQtBridge * _applicationSignalBridge; }; ApplicationApi::ApplicationApi(QObject *parent) : QObject(parent), d_ptr(new ApplicationApiPrivate(this)) { Q_D(ApplicationApi); QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &ApplicationApi::aboutToQuit); QObject::connect(d->_applicationEventListener, &ApplicationApiEventListener::activated, this, &ApplicationApi::activated); QObject::connect(d->_applicationEventListener, &ApplicationApiEventListener::deactivated, this, &ApplicationApi::deactivated); QObject::connect(d->_applicationSignalBridge, &ApplicationSignalToQtBridge::onSignalRaised, this, &ApplicationApi::signalReceived); // We explictly handle the SIGTERM signal case that is being sent // on Touch to an application being killed by the platform. // Upstart sends this signal when the application is closed from app scope. d->_applicationSignalBridge->addSignalHandlerFor(SIGTERM); QScreen * screen = QGuiApplication::primaryScreen(); if (screen) { QObject::connect(screen, &QScreen::orientationChanged, this, &ApplicationApi::screenOrientationChanged); } } ApplicationApi::~ApplicationApi() { Q_D(ApplicationApi); QObject::disconnect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &ApplicationApi::aboutToQuit); QObject::disconnect(d->_applicationEventListener, &ApplicationApiEventListener::activated, this, &ApplicationApi::activated); QObject::disconnect(d->_applicationEventListener, &ApplicationApiEventListener::deactivated, this, &ApplicationApi::deactivated); QObject::disconnect(d->_applicationSignalBridge, &ApplicationSignalToQtBridge::onSignalRaised, this, &ApplicationApi::signalReceived); QScreen * screen = QGuiApplication::primaryScreen(); if (screen) { QObject::disconnect(screen, &QScreen::orientationChanged, this, &ApplicationApi::screenOrientationChanged); } delete d_ptr; } QString ApplicationApi::getApplicationName() const { if ( ! qgetenv("APP_ID").isEmpty()) return qgetenv("APP_ID"); return QCoreApplication::applicationName(); } QString ApplicationApi::getApplicationDataPath() const { QDir dataLocation( QStandardPaths::writableLocation( QStandardPaths::DataLocation)); if (!dataLocation.exists()) { QDir::root().mkpath(dataLocation.absolutePath()); } return dataLocation.absolutePath(); } QString ApplicationApi::getApplicationScreenOrientation() const { QScreen * screen = QGuiApplication::primaryScreen(); return nameFromScreenOrientation(screen->primaryOrientation()); } QString ApplicationApi::getInputMethodName() const { return QString(getenv("QT_IM_MODULE")); } void ApplicationApi::setInputMethodVisible(bool visible) { QGuiApplication::inputMethod()->setVisible(visible); if (visible) QGuiApplication::inputMethod()->show(); else QGuiApplication::inputMethod()->hide(); } QString ApplicationApi::getApplicationPlatform() const { return QGuiApplication::platformName(); } void ApplicationApi::aboutToQuit() { Q_EMIT applicationAboutToQuit(false); } void ApplicationApi::activated() { Q_EMIT applicationActivated(); } void ApplicationApi::deactivated() { Q_EMIT applicationDeactivated(); } void ApplicationApi::signalReceived(int type) { if (type != SIGTERM && type != SIGINT) return; bool killed = (type == SIGTERM); Q_EMIT applicationAboutToQuit(killed); QCoreApplication::quit(); } void ApplicationApi::screenOrientationChanged(Qt::ScreenOrientation orientation) { Q_EMIT applicationScreenOrientationChanged( nameFromScreenOrientation( orientation)); } #include "application-api.moc" unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-icon-utils.h0000644000015301777760000000161112320722666032362 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_ICON_UTILS_H__ #define __UNITY_WEBAPPS_ICON_UTILS_H__ #include namespace UnityWebappsQML { QString getIconPathFor(const QString& iconURI); } #endif // __UNITY_WEBAPPS_ICON_UTILS_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api.cpp0000644000015301777760000004123012320722666031401 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "unity-webapps-api.h" #include "unity-webapps-app-infos.h" #include "unity-webapps-app-model.h" #include #include #include #include #include #include #include #include "unity-webapps-icon-utils.h" #include "unity-webapps-desktop-infos.h" namespace { QString getDesktopFilenameFor(const QString & name, const QString & domain) { return QString("%1.desktop").arg(UnityWebappsQML::buildDesktopInfoFileForWebapp(name, domain)); } } // namespace { const QString UnityWebapps::WEBAPPS_RUNNER_EXEC = "unity-webapps-runner"; UnityWebapps::UnityWebapps(QObject *parent) : QObject(parent) , _model(0) , _appInfos(0) , _handleDesktopFileUpdates(true) {} UnityWebapps::~UnityWebapps() { cleanup(); } void UnityWebapps::cleanup() { delete _appInfos; _appInfos = 0; } void UnityWebapps::init(const QString& name, const QString& url, bool isLocal, const QVariant& args) { Q_UNUSED(name); if (_appInfos != NULL) cleanup(); if (QString(args.typeName()).compare("QVariantMap") != 0) { qDebug() << "Invalid init() parameter types: " << args.typeName(); Q_EMIT initCompleted(false); return; } #define UNITY_WEBAPPS_IS_VALID(name,type) \ ( initArgs.contains(name) && initArgs.value(name).canConvert() ) QVariantMap initArgs = qvariant_cast(args); if ( ! UNITY_WEBAPPS_IS_VALID("name", QString)) { qDebug() << "Invalid init() parameter content (not found or invalid): name is mandatory"; Q_EMIT initCompleted(false); return; } QString displayName = initArgs.value("name").toString(); QString iconUrl = initArgs.contains("iconUrl") && UNITY_WEBAPPS_IS_VALID("iconUrl",QString) ? initArgs.value("iconUrl").toString() : ""; QString domain = initArgs.contains("domain") && UNITY_WEBAPPS_IS_VALID("domain",QString) ? initArgs.value("domain").toString() : ""; if ( ! isLocal && (iconUrl.isEmpty() || domain.isEmpty())) { qDebug() << "Invalid init() parameter content " "(not found or invalid): domain and iconUrl are mandatory for nonlocal apps"; Q_EMIT initCompleted(false); return; } QString desktopId; if (qgetenv("APP_ID").isEmpty()) { desktopId = getDesktopFilenameFor(displayName, domain); } else { desktopId = QString("%1.desktop").arg(QString(qgetenv("APP_ID"))); } qDebug() << "UnityWebapps initialized with desktop id: " << desktopId; bool success = initInternal(name, displayName, domain, iconUrl, url); if (success) buildAppInfos(name, displayName, domain, desktopId, iconUrl); Q_EMIT initCompleted(success); } UnityWebappsAppInfos * UnityWebapps::appInfos() { return _appInfos; } UnityWebappsAppModel* UnityWebapps::model() const { return _model; } void UnityWebapps::setAppModel(UnityWebappsAppModel * model) { if (_model == model) return; _model = model; } bool UnityWebapps::isConfined() const { //Cheap way to know if we work in a confined environment //FIXME: think of a better way to handle desktop/phone specifics #if defined(Q_OS_LINUX) && ! defined(Q_PROCESSOR_X86) return true; #else return false; #endif } void UnityWebapps::buildAppInfos(const QString & name, const QString & displayName, const QString & domain, const QString & desktopId, const QString & iconName) { if (_appInfos != NULL) { qDebug() << "WARNING: Found existing application info for app " << name; return; } _appInfos = new UnityWebappsAppInfos(); _appInfos->setAppName(name); _appInfos->setDisplayName(displayName); _appInfos->setDesktopId(desktopId); _appInfos->setIconName(iconName); _appInfos->setDomain(domain); _appInfos->setModel(_model); Q_EMIT appInfosChanged(_appInfos); } bool UnityWebapps::initInternal(const QString& name, const QString& displayName, const QString& domain, const QString& iconUrl, const QString& url) { Q_UNUSED(name); Q_UNUSED(iconUrl); if ( ! isValidInitForWebappAndModel(domain, displayName, url)) { qDebug() << "Invalid init() call from javascript for webapp " << name << " and current model"; return false; } return true; } bool UnityWebapps::handleDesktopFileUpdates() const { return _handleDesktopFileUpdates; } void UnityWebapps::setHandleDesktopFileUpdates (bool handle) { _handleDesktopFileUpdates = handle; } bool UnityWebapps::isValidInitForWebappAndModel (const QString & domain, const QString & displayName, const QString & url) { if (NULL == _model) return true; if ( ! _model->exists(displayName)) { qDebug() << "Initializing a non-local webapp (not found installed locally)"; return true; } QString modelAppDomain = _model->getDomainFor(displayName); if (modelAppDomain.isEmpty()) { qDebug() << "Validation a weird webapps install: domain name empty for " << displayName; return true; } return modelAppDomain.compare(domain, Qt::CaseInsensitive) == 0 && _model->doesUrlMatchesWebapp(displayName, url); } QString UnityWebapps::getUserSharePath() { QStringList userhomeList = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); if (userhomeList.isEmpty()) { qDebug() << "Error cannot find current '~'"; return QString(); } QDir home(userhomeList.at(0)); return home.absolutePath() + QDir::separator() + ".local/share"; } QString UnityWebapps::getLocalDesktopFilepath(const QString & desktopId) { return getUserSharePath() + QDir::separator() + "applications/" + desktopId; } QString UnityWebapps::generateActionEntryFor(const QString& actionName, const QString& name, const QString& showIn, const QString& exec) { return QString("[Desktop Action %1]\n" "Name=%2\n" "OnlyShowIn=%3\n" "Exec=%4\n\n") .arg(actionName) .arg(name) .arg(showIn) .arg(exec); } QString UnityWebapps::getUrlLaunchExec(const QString & webappName, const QString & url) { return QString("%1 --webapp='%2' %3") .arg(WEBAPPS_RUNNER_EXEC) .arg(webappName.toUtf8().toBase64().data()) .arg(url); } QString UnityWebapps::generateActionsEntry(const QString & webappName) { const size_t MAX_ACTIONS_INDEX = 9; QString content; Q_FOREACH(const QString& actionName, _actions.keys()) { if (_actions[actionName].idx > MAX_ACTIONS_INDEX) continue; QStringList showIn; QString exec; if (_actions[actionName].type & STATIC_ACTION) { exec = getUrlLaunchExec(webappName, _actions[actionName].url); showIn.append("Unity"); } if (_actions[actionName].type & LAUNCHER_ACTION) { showIn.append("Unity"); } if (_actions[actionName].type & INDICATOR_ACTION) { showIn.append("Messaging Menu"); } content.append (generateActionEntryFor (QString("S%1").arg(_actions[actionName].idx), actionName, showIn.join(";"), exec)); } return content; } QMap UnityWebapps::collectActionIndexes() { QMap indexes; Q_FOREACH(const QString& name, _actions.keys()) { indexes[_actions[name].idx] = _actions[name]; } return indexes; } int UnityWebapps::findNextAvailableActionIndex(const QMap & indexes) { int idx = 1; while (1) { if ( ! indexes.contains(idx)) break; idx++; } return idx; } QString UnityWebapps::addAction (const QString& name, UnityWebapps::ActionTypeFlags type, const QString& url) { if (_actions.contains(name)) { if ((_actions[name].type & type) && (0 == _actions[name].url.compare(url))) return QString(); _actions[name].type |= type; _actions[name].url = url; } else { _actions[name] = ActionInfos(name, type, findNextAvailableActionIndex(collectActionIndexes()), url); } updateDesktopFileContent(); return QString("S%1").arg(_actions[name].idx); } QString UnityWebapps::addLauncherAction(const QString& name) { // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return QString(); return addAction(name, LAUNCHER_ACTION); } QString UnityWebapps::addIndicatorAction (const QString& name) { // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return QString(); return addAction(name, INDICATOR_ACTION); } QString UnityWebapps::addStaticAction (const QString& name, const QString& url) { // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return QString(); return addAction(name, STATIC_ACTION, url); } void UnityWebapps::removeLauncherAction(const QString& name) { // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return; if (_actions.contains(name) && (_actions[name].type & LAUNCHER_ACTION)) { _actions[name].type &= ~LAUNCHER_ACTION; updateDesktopFileContent(); } } void UnityWebapps::removeLauncherActions() { // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return; bool found = false; Q_FOREACH(const QString & actionName, _actions.keys()) { if (_actions[actionName].type & LAUNCHER_ACTION) { _actions[actionName].type &= ~LAUNCHER_ACTION; found = true; } } if (found) updateDesktopFileContent(); } QString UnityWebapps::extractFromGlobalDesktopFile(const QString & desktopFilename) { if (desktopFilename.isEmpty()) return QString(); QString DESKTOP_FILE_LOCATION = "/usr/share/applications"; // Allow an override for more granular & flexible testing purposes if (qgetenv("UNITY_WEBAPPS_QML_GLOBAL_DESKTOP_FILE_LOCATION").data() != NULL) { DESKTOP_FILE_LOCATION = QString(qgetenv("UNITY_WEBAPPS_QML_GLOBAL_DESKTOP_FILE_LOCATION")); qDebug() << "Using " << DESKTOP_FILE_LOCATION << " as a global desktop file location search path"; } QFileInfo fileInfo(QString("%1/%2") .arg(DESKTOP_FILE_LOCATION) .arg(desktopFilename)); if ( ! fileInfo.isFile() || ! fileInfo.isReadable()) return QString(); QSettings desktopFileSettings(fileInfo.absoluteFilePath(), QSettings::IniFormat); desktopFileSettings.beginGroup("Desktop Entry"); QVariant execValue = desktopFileSettings.value("Exec"); // The exec line sometimes contains comma separated args in the // command line, e.g. --webappUrlPatterns=1,2,3. In this case // QSettings interprets this as a StringList instead of giving us // the raw value. QString execLine; if (execValue.type() == QVariant::StringList) { execLine = execValue.toStringList().join(","); } else { execLine = execValue.toString(); } desktopFileSettings.endGroup(); return execLine; } QString UnityWebapps::getDesktopFileContent() { if ( ! appInfos()) return QString(); QString webappName = appInfos()->displayName(); QString iconName = appInfos()->iconName(); QString desktopId = appInfos()->desktopId(); QString domain = appInfos()->domain(); QString appId = QString(desktopId).replace(".desktop", ""); QString execCommandLine = extractFromGlobalDesktopFile(appInfos()->desktopId()); if (execCommandLine.isEmpty()) { execCommandLine = QString("%4 -n '%5' -d '%6' %u") .arg(WEBAPPS_RUNNER_EXEC) .arg(QString(webappName.toUtf8().toBase64().data())) .arg(domain); } QString content = QString("[Desktop Entry]\n" "Name=%1\n" "Type=Application\n" "Icon=%2\n" "Actions=S1;S2;S3;S4;S5;S6;S7;S8;S9;S10;\n" "StartupWMClass=%3\n" "Exec=%4\n\n" "%5") .arg(webappName) .arg(UnityWebappsQML::getIconPathFor(iconName)) .arg(appId) .arg(execCommandLine) .arg( ! webappName.isEmpty() ? generateActionsEntry(webappName) : QString("")); return content; } void UnityWebapps::updateDesktopFileContent () { // There is currently an issue on Ubuntu Desktop with webapps // running in the container and bamf/unity that when // a local desktop file exists (and a webapp icon has been pinned // to the launcher through its global /usr/share desktop file), // the webapp icons are duplicated in the launcher. // Various fixes have been made to mitigate the issue in bamf // but it seems to still be around. // This is voluntarily discarded for now and left around to get // to the bottom of the issue in a timely fashion. #if 0 // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return; if ( ! handleDesktopFileUpdates()) return; if ( ! appInfos() || appInfos()->desktopId().isEmpty()) { qDebug() << "Cannot update local desktop file content"; return; } QString desktopFilePath = QDir::cleanPath (getLocalDesktopFilepath (appInfos()->desktopId())); QFile f(desktopFilePath); if ( ! f.open(QIODevice::WriteOnly)) { qWarning() << "Could not create/access desktop file: " << desktopFilePath; return; } f.write(getDesktopFileContent().toUtf8()); f.close(); #endif } void UnityWebapps::ensureLocalApplicationsPathExists() { // we bail out earlier (until we can do it w/ a builtin func) when // in a confined environment. if (isConfined ()) return; QString shareDirPath (getUserSharePath()); if (shareDirPath.isEmpty()) { qDebug() << "Error while trying to get current session home directory"; return; } shareDirPath += QDir::separator() + QString("applications/"); // Create the directory if it doesn't exist QDir shareDir(shareDirPath); if (!shareDir.exists()) { shareDir.mkpath("."); } } // QMLParserStatus void UnityWebapps::classBegin() {} void UnityWebapps::componentComplete() {} ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.hunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parse0000644000015301777760000000510512320722666033544 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_APP_MANIFEST_H__ #define __UNITY_WEBAPPS_APP_MANIFEST_H__ #include #include #include #include "unity-webapps-common-priv.h" /*! * \brief Data view of a given WebApp manifest * * Describes a given WebApp and its execution environment. */ struct ManifestFileInfo { // Name of the WebApp QString name; // Domain associated with the WebApp (TLD) QString domain; // Homepage that should be used when the webapp is being launched QString homepage; // List of urls for which the WebApp applies (wildcard are allowed) QStringList includes; // List of javascript files that correspond to script names for the WebApp QStringList scripts; // List of javascript files required by the WebApp (but not included) QStringList requires; // The currently selected chrome option for this WebApp QStringList chromeOptions; }; /*! * \brief Option type for ManifestFileInfo */ typedef Fallible ManifestFileInfoOption; /*! * \brief The UnityWebappsAppManifestParser class */ class UnityWebappsAppManifestParser : public QObject { public: Q_OBJECT public: UnityWebappsAppManifestParser(QObject *parent = 0); virtual ~UnityWebappsAppManifestParser(); /*! * \brief parse * \param manifest * \return */ virtual ManifestFileInfoOption parse (QFileInfo manifest); private: /*! * \brief parseArray * \param parent * \param name * \return */ QStringList parseArray(const QJsonObject& parent, const QString& name); QStringList parseChromeOptions(const QString& options); /*! * \brief parseContent * \param content * \param infos * \return */ bool parseContent(const QString& content, ManifestFileInfo * infos); }; #endif // __UNITY_WEBAPPS_APP_MANIFEST_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/plugin.pro0000644000015301777760000000342112320722666027337 0ustar pbusernogroup00000000000000include(../../../../common-project-config.pri) include(../../../../common-vars.pri) CONFIG += qt plugin no_keywords unix { CONFIG += link_pkgconfig PKGCONFIG += libnotify \ messaging-menu \ glib-2.0 \ gio-2.0 \ unity \ unity-action-qt-1 } TEMPLATE = lib TARGET = UnityWebApps DESTDIR = ../ CONFIG += \ link_pkgconfig \ plugin \ qt QT += core qml SOURCES += \ qml-plugin.cpp \ unity-webapps-api.cpp \ unity-webapps-api-notifications.cpp \ unity-webapps-api-messaging-menu.cpp \ unity-webapps-api-launcher.cpp \ unity-webapps-api-mediaplayer.cpp \ unity-webapps-app-model.cpp \ unity-webapps-app-manifest-parser.cpp \ unity-webapps-app-model-filter-proxy.cpp \ unity-webapps-app-infos.cpp \ unity-webapps-desktop-infos.cpp \ unity-webapps-icon-utils.cpp \ callback.cpp \ abstract-item-model-adaptor.cpp \ application-api.cpp \ application-signal-to-qt-bridge.cpp HEADERS += \ qml-plugin.h \ unity-webapps-api.h \ unity-webapps-api-notifications.h \ unity-webapps-api-messaging-menu.h \ unity-webapps-api-launcher.h \ unity-webapps-api-mediaplayer.h \ unity-webapps-app-model.h \ unity-webapps-app-manifest-parser.h \ unity-webapps-common-priv.h \ unity-webapps-app-model-filter-proxy.h \ unity-webapps-app-infos.h \ unity-webapps-desktop-infos.h \ unity-webapps-icon-utils.h \ callback.h \ abstract-item-model-adaptor.h \ application-api.h \ application-signal-to-qt-bridge.h DEFINES += \ API_URI=\\\"$${API_URI}\\\" # plugin deployment PLUGIN_INSTALL_PATH = $$[QT_INSTALL_QML]/$$replace(API_URI, \\., /) target.path = $${PLUGIN_INSTALL_PATH} INSTALLS += target unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp0000644000015301777760000000462612320722666030120 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "qml-plugin.h" #include #include #include "unity-webapps-api.h" #include "unity-webapps-api-notifications.h" #include "unity-webapps-api-messaging-menu.h" #include "unity-webapps-api-launcher.h" #include "unity-webapps-api-mediaplayer.h" #include "unity-webapps-app-model-filter-proxy.h" #include "unity-webapps-app-model.h" #include "unity-webapps-app-infos.h" #include "application-api.h" #include "abstract-item-model-adaptor.h" #include "callback.h" #include static QObject *createApplicationApi(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine); Q_UNUSED(scriptEngine); return new ApplicationApi(); } void WebappsQmlPlugin::registerTypes(const char *uri) { // bindings qmlRegisterType (uri, 0, 1, "UnityWebappsBase"); qmlRegisterType (uri, 0, 1, "UnityWebappsNotificationsBinding"); qmlRegisterType (uri, 0, 1, "UnityWebappsMessagingBinding"); qmlRegisterType (uri, 0, 1, "UnityWebappsLauncherBinding"); qmlRegisterType (uri, 0, 1, "UnityWebappsMediaPlayerBinding"); // misc qmlRegisterType (uri, 0, 1, "UnityWebappsAppModel"); qmlRegisterType (uri, 0, 1, "UnityWebappsAppModelFilterProxy"); qmlRegisterType (uri, 0, 1, "UnityWebappsCallback"); qmlRegisterType (uri, 0, 1, "UnityWebappsAppInfos"); // TODO bump version qmlRegisterType (uri, 0, 1, "AbstractItemModelAdaptor"); // qmlRegisterSingletonType(uri, 0, 1, "ApplicationApi", createApplicationApi); } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cppunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-p0000644000015301777760000000364412320722666033454 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "unity-webapps-app-model-filter-proxy.h" #include "unity-webapps-app-model.h" UnityWebappsAppModelFilterProxy::UnityWebappsAppModelFilterProxy(QObject *parent) : QSortFilterProxyModel(parent) {} UnityWebappsAppModelFilterProxy::~UnityWebappsAppModelFilterProxy() {} UnityWebappsAppModel* UnityWebappsAppModelFilterProxy::sourceModel () const { return sourceModel(); } void UnityWebappsAppModelFilterProxy::setsourceModel (UnityWebappsAppModel * model) { setSourceModel(model); Q_EMIT sourceModelChanged(); } QString UnityWebappsAppModelFilterProxy::webappName () const { return _name; } void UnityWebappsAppModelFilterProxy::setwebappName (const QString& name) { _name = name; Q_EMIT webappNameChanged(); } bool UnityWebappsAppModelFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (_name.isEmpty() || !sourceModel()) { // filter out everything return false; } QString rowName = sourceModel()->data(sourceModel()->index(source_row, 0, source_parent), UnityWebappsAppModel::Name).toString(); return 0 == _name.toLower().compare(rowName.toLower()); } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/qml-plugin.h0000644000015301777760000000176412320722666027565 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __WEBAPPS_QML_PLUGIN_H__ #define __WEBAPPS_QML_PLUGIN_H__ #include class WebappsQmlPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: void registerTypes(const char *uri); }; #endif // __WEBAPPS_QML_PLUGIN_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-mediaplayer.h0000644000015301777760000000500312320722666033336 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef __UNITY_WEBAPPS_MEDIA_PLAYER_H__ #define __UNITY_WEBAPPS_MEDIA_PLAYER_H__ #include #include #include "unity-webapps-app-model.h" #include "unity-webapps-app-infos.h" #include "callback.h" class UnityWebappsMediaPlayerPrivate; class UnityWebappsMediaPlayer: public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_ENUMS(PlaybackState) public: enum PlaybackState { PLAYING, PAUSED }; public: UnityWebappsMediaPlayer(QObject * parent = 0); virtual ~UnityWebappsMediaPlayer(); // API functions Q_INVOKABLE void onPlayPause (UnityWebappsCallback * callback); Q_INVOKABLE void onPrevious (UnityWebappsCallback * callback); Q_INVOKABLE void onNext (UnityWebappsCallback * callback); Q_INVOKABLE void setTrack (const QString & artist, const QString & album, const QString & title, const QString & artLocation); Q_INVOKABLE void setCanGoNext (bool state); Q_INVOKABLE void setCanGoPrevious (bool state); Q_INVOKABLE void setCanPlay (bool state); Q_INVOKABLE void setCanPause (bool state); Q_INVOKABLE QString getTrack (); Q_INVOKABLE bool getCanGoNext (); Q_INVOKABLE bool getCanGoPrevious (); Q_INVOKABLE bool getCanPlay (); Q_INVOKABLE bool getCanPause (); Q_INVOKABLE void setPlaybackState(PlaybackState state); Q_INVOKABLE PlaybackState getPlaybackState (); // class specific funcs void classBegin(); void componentComplete(); public Q_SLOTS: void onAppInfosChanged(UnityWebappsAppInfos *appInfos); Q_SIGNALS: void raised(); private: UnityWebappsMediaPlayerPrivate *d_ptr; Q_DECLARE_PRIVATE(UnityWebappsMediaPlayer) }; #endif // __UNITY_WEBAPPS_MEDIA_PLAYER_H__ unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-icon-utils.cpp0000644000015301777760000000201412320722666032713 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include "unity-webapps-icon-utils.h" QString UnityWebappsQML::getIconPathFor (const QString& iconURI) { static const QString ICON_URI_SCHEME = "icon://"; if (iconURI.startsWith (ICON_URI_SCHEME)) { return iconURI.right(iconURI.count() - ICON_URI_SCHEME.count()); } return QString(); } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/abstract-item-model-adaptor.h0000644000015301777760000000310212320722666032751 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #ifndef ABSTRACT_ITEM_MODELADAPTOR_H #define ABSTRACT_ITEM_MODELADAPTOR_H #include #include #include class AbstractItemModelAdaptorPrivate; class AbstractItemModelAdaptor : public QObject { Q_OBJECT Q_PROPERTY(QObject * itemModel READ itemModel \ WRITE setItemModel NOTIFY itemModelChanged) public: explicit AbstractItemModelAdaptor(QObject *parent = 0); ~AbstractItemModelAdaptor(); Q_INVOKABLE QVariant itemAt(int index, const QString & role); Q_INVOKABLE QStringList roles(); Q_INVOKABLE int rowCount(); QObject * itemModel(); void setItemModel(QObject *); Q_SIGNALS: void itemModelChanged(); public Q_SLOTS: private: int roleIndexFromName(const QString & name); AbstractItemModelAdaptorPrivate *d_ptr; Q_DECLARE_PRIVATE(AbstractItemModelAdaptor) }; #endif // ABSTRACTITEMMODELADAPTOR_H ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-mediaplayer.cppunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-mediaplayer.cp0000644000015301777760000002354112320722666033520 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include #include #include #include #include #include #include #include #include #include #include #include "unity-webapps-desktop-infos.h" #include "unity-webapps-app-infos.h" #include "unity-webapps-api-mediaplayer.h" #define API_CALL_HEADER() do { \ d->init(); \ if (!d->_player) \ return; \ } while(0) struct UnityWebappsMediaPlayerPrivate { UnityWebappsMediaPlayerPrivate (UnityWebappsMediaPlayer * qq); ~UnityWebappsMediaPlayerPrivate (); void clear(); void init(); void onRaised(); UnityWebappsAppInfos *_appInfos; UnityMusicPlayer *_player; UnityTrackMetadata * _metadata; QObject* _raise_callback; QObject* _playpause_callback; QObject* _next_callback; QObject* _previous_callback; UnityWebappsMediaPlayer* const q_ptr; Q_DECLARE_PUBLIC(UnityWebappsMediaPlayer) }; static void _uwq_media_callback_raised (UnityMusicPlayer *player, gpointer user_data) { Q_UNUSED(player); UnityWebappsMediaPlayerPrivate* self = static_cast(user_data); if(self) self->onRaised(); } static void _uwq_media_callback_play_pause (UnityMusicPlayer *player, gpointer user_data) { Q_UNUSED(player); UnityWebappsMediaPlayerPrivate* self = static_cast(user_data); if (self && self->_playpause_callback) QMetaObject::invokeMethod(self->_playpause_callback, "trigger"); } static void _uwq_media_callback_next (UnityMusicPlayer *player, gpointer user_data) { Q_UNUSED(player); UnityWebappsMediaPlayerPrivate* self = static_cast(user_data); if (self && self->_next_callback) QMetaObject::invokeMethod(self->_next_callback, "trigger"); } static void _uwq_media_callback_previous (UnityMusicPlayer *player, gpointer user_data) { Q_UNUSED(player); UnityWebappsMediaPlayerPrivate* self = static_cast(user_data); if (self && self->_previous_callback) QMetaObject::invokeMethod(self->_previous_callback, "trigger"); } UnityWebappsMediaPlayerPrivate::UnityWebappsMediaPlayerPrivate (UnityWebappsMediaPlayer * qq) : _appInfos(0) , _player(0) , _metadata(0) , _raise_callback (0) , _playpause_callback (0) , _next_callback (0) , _previous_callback (0) , q_ptr(qq) {} UnityWebappsMediaPlayerPrivate::~UnityWebappsMediaPlayerPrivate() { clear(); } void UnityWebappsMediaPlayerPrivate::onRaised() { Q_Q(UnityWebappsMediaPlayer); Q_EMIT q->raised(); if (_raise_callback) QMetaObject::invokeMethod(_raise_callback, "trigger"); } void UnityWebappsMediaPlayerPrivate::clear() { if (_player && G_IS_OBJECT(_player)) { unity_music_player_set_is_blacklisted (_player, TRUE); g_object_unref(_player); _player = 0; } if (_metadata) { _metadata = 0; g_object_unref (_metadata); } _appInfos = 0; _raise_callback = 0; _playpause_callback = 0; _next_callback = 0; _previous_callback = 0; } void UnityWebappsMediaPlayerPrivate::init() { if (Q_UNLIKELY(_player != NULL)) return; if (Q_UNLIKELY(_appInfos == NULL)) { qDebug() << "Trying to initialize the MediaPlayer binding with invalid context"; return; } QString displayName = _appInfos->displayName(); if (displayName.isEmpty()) { qDebug() << "MediaPlayer backend: invalid display name (empty)"; return; } QString desktopId = _appInfos->desktopId(); if (desktopId.isEmpty()) { qDebug() << "MediaPlayer backend: invalid desktop id (empty)"; return; } _player = unity_music_player_new (desktopId.toUtf8().data()); unity_music_player_set_title (_player, displayName.toUtf8().data()); unity_music_player_set_is_blacklisted (_player, FALSE); g_signal_connect (_player, "raise", G_CALLBACK (_uwq_media_callback_raised), this); g_signal_connect (_player, "play_pause", G_CALLBACK (_uwq_media_callback_play_pause), this); g_signal_connect (_player, "next", G_CALLBACK (_uwq_media_callback_next), this); g_signal_connect (_player, "previous", G_CALLBACK (_uwq_media_callback_previous), this); } UnityWebappsMediaPlayer::UnityWebappsMediaPlayer(QObject *parent) : QObject(parent), d_ptr(new UnityWebappsMediaPlayerPrivate(this)) {} UnityWebappsMediaPlayer::~UnityWebappsMediaPlayer() { delete d_ptr; } void UnityWebappsMediaPlayer::onAppInfosChanged(UnityWebappsAppInfos *appInfos) { Q_D(UnityWebappsMediaPlayer); bool wasInit = false; if (d->_player) { wasInit = true; d->clear(); } d->_appInfos = appInfos; if (wasInit) d->init(); } void UnityWebappsMediaPlayer::onPlayPause (UnityWebappsCallback * callback) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); d->_playpause_callback = callback; } void UnityWebappsMediaPlayer::onPrevious (UnityWebappsCallback * callback) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); d->_previous_callback = callback; } void UnityWebappsMediaPlayer::onNext (UnityWebappsCallback * callback) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); d->_next_callback = callback; } void UnityWebappsMediaPlayer::setTrack (const QString & artist, const QString & album, const QString & title, const QString & artLocation) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); if (! d->_metadata) d->_metadata = unity_track_metadata_new (); unity_track_metadata_set_artist (d->_metadata, artist.toUtf8().data()); unity_track_metadata_set_album (d->_metadata, album.toUtf8().data()); unity_track_metadata_set_title (d->_metadata, title.toUtf8().data()); if ( ! artLocation.isEmpty()) { GFile * f = g_file_new_for_path (artLocation.toUtf8().data()); unity_track_metadata_set_art_location (d->_metadata, f); g_object_unref (G_OBJECT (f)); } unity_music_player_set_current_track (d->_player, d->_metadata); } void UnityWebappsMediaPlayer::setCanGoNext (bool state) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); unity_music_player_set_can_go_next(d->_player, state); } void UnityWebappsMediaPlayer::setCanGoPrevious (bool state) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); unity_music_player_set_can_go_previous(d->_player, state); } void UnityWebappsMediaPlayer::setCanPlay (bool state) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); unity_music_player_set_can_play(d->_player, state); } void UnityWebappsMediaPlayer::setCanPause (bool state) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); unity_music_player_set_can_pause(d->_player, state); } void UnityWebappsMediaPlayer::setPlaybackState(PlaybackState state) { Q_D(UnityWebappsMediaPlayer); API_CALL_HEADER(); unity_music_player_set_playback_state(d->_player, (UnityPlaybackState) state); } UnityWebappsMediaPlayer::PlaybackState UnityWebappsMediaPlayer::getPlaybackState () { Q_D(UnityWebappsMediaPlayer); d->init(); if (!d->_player) return PLAYING; return (PlaybackState) unity_music_player_get_playback_state(d->_player); } QString UnityWebappsMediaPlayer::getTrack () { Q_D(UnityWebappsMediaPlayer); d->init(); if (!d->_player) return QString(); UnityTrackMetadata * metadata = unity_music_player_get_current_track(d->_player); QString artist = unity_track_metadata_get_artist (metadata); QString title = unity_track_metadata_get_title (metadata); QString album = unity_track_metadata_get_album (metadata); QString track = QString("%1;%2;%3").arg(artist.toUtf8().toBase64().data()) .arg(title.toUtf8().toBase64().data()) .arg(album.toUtf8().toBase64().data()); qDebug() << "get track " << track; return track; } bool UnityWebappsMediaPlayer::getCanGoNext () { Q_D(UnityWebappsMediaPlayer); d->init(); if (!d->_player) return false; return unity_music_player_get_can_go_next(d->_player); } bool UnityWebappsMediaPlayer::getCanGoPrevious () { Q_D(UnityWebappsMediaPlayer); d->init(); if (!d->_player) return false; return unity_music_player_get_can_go_previous(d->_player); } bool UnityWebappsMediaPlayer::getCanPlay () { Q_D(UnityWebappsMediaPlayer); d->init(); if (!d->_player) return false; return unity_music_player_get_can_play(d->_player); } bool UnityWebappsMediaPlayer::getCanPause () { Q_D(UnityWebappsMediaPlayer); d->init(); if (!d->_player) return false; return unity_music_player_get_can_pause(d->_player); } void UnityWebappsMediaPlayer::classBegin() { } void UnityWebappsMediaPlayer::componentComplete() { } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-notifications.cppunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/plugin/unity-webapps-api-notifications.0000644000015301777760000000403512320722666033547 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ #include "unity-webapps-api-notifications.h" #include #include UnityWebappsNotification::UnityWebappsNotification(QObject *parent) : QObject(parent) {} UnityWebappsNotification::~UnityWebappsNotification() { notify_uninit(); } void UnityWebappsNotification::show(const QString& summary, const QString& body, const QString& icon) { NotifyNotification *notification; notification = notify_notification_new (summary.toUtf8().data(), body.toUtf8().data(), QFileInfo(icon).canonicalFilePath().toUtf8().data()); notify_notification_set_timeout (notification, 4); notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL); GError *error = NULL; notify_notification_show (notification, &error); if (error) { qWarning() << error->message; } } void UnityWebappsNotification::setName(const QString& name) { _applicationName = name; //TODO: this is rather bad, not "closed" at all, very error prone notify_init(_applicationName.toUtf8().data()); } QString UnityWebappsNotification::name() const { return _applicationName; } void UnityWebappsNotification::classBegin() { } void UnityWebappsNotification::componentComplete() { } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/Settings.qml0000644000015301777760000000146212320722666026337 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 Item { /** * */ property bool injectExtraUbuntuApis: false property bool requiresInit: true } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/UnityWebAppsBackendComponents.js0000644000015301777760000020154412320722666032275 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ .import Ubuntu.Content 0.1 as ContentHubBridge .import Ubuntu.Components 0.1 as ComponentsBridge var _backends = {}; function __set(id, component) { _backends[id] = component; }; function __areValidParams(params) { function __has(o,n) { return n in o && o[n] != null && (typeof o[n] === 'string' ? o[n] !== "" : true); }; return params && __has(params, 'name') && __has(params, 'displayName'); }; function __createQmlObject(qmlStatement, parentItem, params) { var component = null; var error = null; try { component = Qt.createQmlObject(qmlStatement, parentItem); } catch(e) { error = JSON.stringify(e.qmlErrors); } return { object: component, error: error}; }; //TODO: bad mechanism, it could possibly be that the "base" backend is // ready after the "notify" one ... which is bad and could enable calls // to notify w/o base ready var _backendReadyListeners = {}; function __onBackendReady(name) { if (!(name instanceof String) || name.length !== 0) return; var listeners = _backendReadyListeners[name]; if (listeners && listeners instanceof Array && listeners.length !== 0) { listeners.forEach(function (listener) { try { listener(name); } catch (e) {}; }); } }; function signalOnBackendReady(name, func) { if (typeof(name) != "string" || name.length === 0) return; if (!(func instanceof Function)) return; // check if backend already ready if (!!get(name)) { console.debug('Backend ready: ' + name); func(name); return; } if (!_backendReadyListeners[name]) _backendReadyListeners[name] = []; _backendReadyListeners[name].push(func); } function UnityActionsBackendAdaptor(parentItem, actionsContext) { this._actions = {}; this._actionsContext = actionsContext; }; UnityActionsBackendAdaptor.prototype.destroy = function () { this.clearActions(); } UnityActionsBackendAdaptor.prototype.__normalizeName = function (actionName) { return actionName.replace(/^\/+/, ''); } UnityActionsBackendAdaptor.prototype.__actionExists = function (actionName) { if (!actionName || typeof(actionName) != 'string' || actionName.lenght === 0) return false; return this._actions[actionName] != null && this._actions[actionName].action != null; }; UnityActionsBackendAdaptor.prototype.addAction = function (_actionText, callback, id) { var actionText = this.__normalizeName(_actionText); if (this.__actionExists(actionText)) this.clearAction(actionText); var params = ' text: "' + actionText + '";' + ' enabled: true; ' + (id ? ('name: ' + '"' + id + '"') : ''); var action = __createQmlObject('import Ubuntu.Unity.Action 1.0 as UnityActions; \ UnityActions.Action { ' + params + ' }', this._actionsContext).object; this._actionsContext.addAction(action); action.triggered.connect(callback); this._actions[actionText] = { action: action, callback: callback}; } UnityActionsBackendAdaptor.prototype.clearAction = function (_actionName) { var actionName = this.__normalizeName(_actionName); if ( ! this.__actionExists(actionName)) return; try { this._actionsContext.removeAction(this._actions[actionName].action); this._actions[actionName].action.enabled = false; this._actions[actionName].action.triggered.disconnect(this._actions[actionName].callback); this._actions[actionName] = null; } catch(e) { console.debug('Error while removing an action: ' + e); } } UnityActionsBackendAdaptor.prototype.clearActions = function () { for(var action in this._actions) { if (this._actions.hasOwnProperty(action) && this._actions[action] != null) this.clearAction(action); } } /*! \internal Extracts the properties of a given js object and tries to create a string for the definition of a QML object w/ those values. e.g. params = {name: "myname", version: 1} -> "name: 'myname'; version: 1" It assumes a lot and is fragile (no array, complex object support, error handling, etc,) FIXME: Shamefully hacky */ function __extractParams(params) { if (!params || !(params instanceof Object)) return ""; var extracted = ""; for (var p in params) { if (params.hasOwnProperty(p) && params[p] != null) { extracted += p + ":" + JSON.stringify(params[p]) + "; "; } } return extracted; } function get(id) { return _backends[id]; }; function UbuntuBindingBackendDelegate(parent) { this._parent = parent; this._id = 0; this._objects = {}; this._last_proxy_id = 0; } UbuntuBindingBackendDelegate.prototype = { createQmlObject: function(uri, version, component, properties) { var statement = 'import ' + uri + ' ' + version + '; ' + component + ' { ' + __extractParams(properties) + ' }'; var result = __createQmlObject(statement, this._parent); if (result.error != null) { console.debug('Error while creating object: ' + uri + '.' + component + ' : ' + result.error); return null; } var id = this._generateObjectId(uri, component); this._objects[id] = result.object; return {object: this._objects[id], id: id}; }, parent: function() { return this._parent; }, parentView: function() { return this._parent ? this._parent.bindee : null; }, isObjectProxyInfo: function(info) { return 'type' in info && info.type === 'object-proxy' && 'apiid' in info && 'objecttype' in info && 'objectid' in info; }, deleteId: function(id) { if (this._objects[id] != null) { delete this._objects[id]; this._objects[id] = null; } }, objectFromId: function(id) { return id != null ? this._objects[id] : null; }, storeQmlObject: function(object, uri, version, component, properties) { var id = this._generateObjectId(uri, component); console.debug('got an id: ' + id) this._objects[id] = object; return id; }, createModelAdaptorFor: function(model) { var adaptor = Qt.createQmlObject('import Ubuntu.UnityWebApps 0.1 \ as UW; UW.AbstractItemModelAdaptor {}', this._parent); adaptor.itemModel = model; return adaptor; }, _generateObjectId: function(uri, name) { var candidate = uri + name + this._id; while (this._objects[candidate] != undefined) { ++this._last_proxy_id; candidate = uri + name + this._last_proxy_id; } return candidate; } }; var backendDelegate; function createBackendDelegate(parentItem) { backendDelegate = new UbuntuBindingBackendDelegate(parentItem); } /** * \brief creates all the backends * * \param */ function createAllWithAsync(parentItem, params, eventHandlers) { if (!__areValidParams(params)) { //TODO: error reporting throw new Error("Invalid creation parameters"); } var extracted = __extractParams(params); function connectAppRaisedEvent(target) { if (target && eventHandlers && eventHandlers.onAppRaised) target.raised.connect(function() { try { eventHandlers.onAppRaised(); } catch(e){} }); } //FIXME:!!! lots of duplicated stuff var result = __createQmlObject('import Ubuntu.UnityWebApps 0.1 as Backends; \ Backends.UnityWebappsBase { }', parentItem, params); if (result.error != null) { console.debug('Could not create base backend: ' + result.error); clearAll(); return false; } var apiBase = result.object; apiBase.model = parentItem.model; __set("base", apiBase); __onBackendReady("base"); // notifications result = __createQmlObject('import Ubuntu.UnityWebApps 0.1 as Backends; \ Backends.UnityWebappsNotificationsBinding { name: "' + params.name + '"; }', parentItem, params); if (result.error != null) { console.debug('Could not create notifications backend: ' + result.error); clearAll(); return false; } __set("notify", result.object); __onBackendReady("notify"); // launcher result = __createQmlObject('import Ubuntu.UnityWebApps 0.1 as Backends; \ Backends.UnityWebappsLauncherBinding { }', parentItem, params); if (result.error != null) { console.debug('Could not create launcher backend: ' + result.error); clearAll(); return false; } var launcher = result.object; apiBase.appInfosChanged.connect(function(appInfos) { launcher.onAppInfosChanged(appInfos); }); __set("launcher", launcher); __onBackendReady("launcher"); // media player result = __createQmlObject('import Ubuntu.UnityWebApps 0.1 as Backends; \ Backends.UnityWebappsMediaPlayerBinding { }', parentItem, params); if (result.error != null) { console.debug('Could not create MediaPlayer backend: ' + result.error); clearAll(); return false; } var mediaplayer = result.object; apiBase.appInfosChanged.connect(function(appInfos) { mediaplayer.onAppInfosChanged(appInfos); }); __set("mediaplayer", mediaplayer); __onBackendReady("mediaplayer"); connectAppRaisedEvent(mediaplayer); // messaging menu result = __createQmlObject('import Ubuntu.UnityWebApps 0.1 as Backends; \ Backends.UnityWebappsMessagingBinding { }', parentItem, params); if (result.error != null) { console.debug('Could not create messaging menu backend: ' + result.error); clearAll(); return false; } // model have to be manuall set var messagingmenu = result.object; apiBase.appInfosChanged.connect(function(appInfos) { messagingmenu.onAppInfosChanged(appInfos); }); __set("messaging", messagingmenu); __onBackendReady("messaging"); connectAppRaisedEvent(messagingmenu); // extra actions set for the launcher/messaging-menu if (parentItem.actionsContext) { __set("indicator-actions", new UnityActionsBackendAdaptor(parentItem, parentItem.actionsContext)); __onBackendReady("indicator-actions"); } // Unity actions/HUD //FIXME: find a better way to access parentItem.actionsContext if (parentItem.actionsContext) { __set("hud", new UnityActionsBackendAdaptor(parentItem, parentItem.actionsContext)); __onBackendReady("hud"); } } function clearAll () { if (_backends.base) { _backends.base.destroy(); _backends['base'] = null; } if (_backends.hud) { _backends.hud.destroy(); _backends['hud'] = null; } if (_backends.notify) { _backends.notify.destroy(); _backends['notify'] = null; } if (_backends.launcher) { _backends.launcher.destroy(); _backends['launcher'] = null; } if (_backends['indicator-actions']) { _backends['indicator-actions'].destroy(); _backends['indicator-actions'] = null; } if (_backends.mediaplayer) { _backends.mediaplayer.destroy(); _backends['mediaplayer'] = null; } if (_backends.messaging) { _backends.messaging.destroy(); _backends['messaging'] = null; } }; /** * * Online Accounts API backend binding * */ function createOnlineAccountsApi(backendDelegate) { var PLUGIN_URI = 'Ubuntu.OnlineAccounts'; var VERSION = 0.1; function Account(account, objectid) { var id = objectid; if ( ! id) { id = backendDelegate.storeQmlObject(transfer, PLUGIN_URI, VERSION, 'Account'); } this._id = id; this._object = account; }; Account.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'OnlineAccounts', objecttype: 'Account', objectid: self._id, // serialize immutable values content: { enabled: self._object.enabled, provider: self._object.provider, displayName: self._object.displayName, accountId: self._object.accountId, } } }, // properties // immutable enabled: function(callback) { this._validate(); callback(this._object.enabled); }, // immutable provider: function(callback) { this._validate(); callback(this._object.provider); }, // immutable displayName: function(callback) { this._validate(); callback(this._object.displayName); }, // immutable accountId: function(callback) { this._validate(); callback(this._object.accountId); }, // method updateDisplayName: function(displayName) { this._validate(); this._object.updateDisplayName(displayName); }, updateEnabled: function(enabled) { this._validate(); this._object.updateEnabled(enabled); }, remove: function(enabled) { this._validate(); this._object.remove(); }, }; function AccountService(service, objectid) { var id = objectid; if ( ! service) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'AccountService'); id = result.id; service = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(service, PLUGIN_URI, VERSION, 'AccountService'); } this._id = id; this._object = service; }; AccountService.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'OnlineAccounts', objecttype: 'AccountService', objectid: self._id, // serialize immutable values content: { accountId: self._object.accountId, enabled: self._object.enabled, serviceEnabled: self._object.serviceEnabled, displayName: self._object.displayName, provider: self.internal.getProvider(self), service: self.internal.getService(self), }, } }, // properties autoSync: function(callback) { this._validate(); callback(this._object.autoSync); }, setAutoSync: function(autoSync, callback) { this._validate(); this._object.autoSync = autoSync; if (callback) callback(); }, // immutable accountId: function(callback) { this._validate(); callback(this._object.accountId); }, // immutable enabled: function(callback) { this._validate(); callback(this._object.enabled); }, // immutable serviceEnabled: function(callback) { this._validate(); callback(this._object.serviceEnabled); }, // immutable displayName: function(callback) { this._validate(); callback(this._object.displayName); }, // immutable provider: function(callback) { this._validate(); callback(this.internal.getProvider(this)); }, // immutable service: function(callback) { this._validate(); callback(this.internal.getService(this)); }, objectHandle: function(callback) { this._validate(); callback(this._object.objectHandle); }, setObjectHandle: function(objectHandle) { this._validate(); this._object.objectHandle = objectHandle; }, // methods authenticate: function(callback) { this._validate(); var onAuthenticated; var onAuthenticationError; var self = this; onAuthenticated = function(reply) { callback({error: null, authenticated: true, data: reply}); self._object.onAuthenticated.disconnect(onAuthenticated); self._object.onAuthenticationError.disconnect(onAuthenticationError); }; onAuthenticationError = function(error){ callback({error: error.message, authenticated: false, data: null, accountId: null}); self._object.onAuthenticated.disconnect(onAuthenticated); self._object.onAuthenticationError.disconnect(onAuthenticationError); }; this._object.onAuthenticated.connect(onAuthenticated); this._object.onAuthenticationError.connect(onAuthenticationError); this._object.authenticate(null); }, // Internal internal: { getService: function(self) { return { id: self._object.service.id, displayName: self._object.service.displayName, iconName: self._object.service.iconName, }; }, getProvider: function(self) { return { id: self._object.provider.id, displayName: self._object.provider.displayName, iconName: self._object.provider.iconName, }; } } }; function Manager() { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'Manager'); this._id = result.id; this._object = result.object; }; Manager.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { return { type: 'object-proxy', apiid: 'OnlineAccounts', objecttype: 'Manager', objectid: this._id, } }, // methods createAccount: function(providerName, callback) { this._validate(); var account = new Account(this._object.createAccount(providerName)); callback(account.serialize()); }, loadAccount: function(id, callback) { this._validate(); var account = new Account(this._object.loadAccount(id)); callback(account.serialize()); }, internal: { loadAccount: function(self, id) { return new Account(self._object.loadAccount(id)); }, }, }; function ProviderModel() { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ProviderModel'); this._id = result.id; this._object = result.object; this._modelAdaptor = backendDelegate.createModelAdaptorFor(this._object); this._roles = this._modelAdaptor.roles(); }; ProviderModel.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); this._modelAdaptor.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { this._validate(); return { type: 'object-proxy', apiid: 'OnlineAccounts', objecttype: 'ProviderModel', objectid: this._id, } }, // properties applicationId: function(callback) { this._validate(); callback(this._object.applicationId); }, setApplicationId: function(applicationId, callback) { this._validate(); this._object.applicationId = applicationId; if (callback) callback(); }, // QAbtractListModel prototype count: function(callback) { this._validate(); if (this._modelAdaptor) { return -1; } callback(this._modelAdaptor.rowCount()); }, at: function(idx, callback) { this._validate(); if (idx >= this.proxy.count || ! this._modelAdaptor) { callback(null); return; } var result = {}; for (var role in this._roles) { result[role] = this._modelAdaptor.itemAt(idx, role); } callback(result); } }; function AccountServiceModel(filterParams) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'AccountServiceModel', filterParams); this._id = result.id; this._object = result.object; this._modelAdaptor = backendDelegate.createModelAdaptorFor(this._object); this._roles = this._modelAdaptor.roles(); // quickly filter out roles that are "tricky" if (this._roles.indexOf('accountServiceHandle') !== -1) { this._roles.splice(this._roles.indexOf('accountServiceHandle'), 1); } if (this._roles.indexOf('accountHandle') !== -1) { this._roles.splice(this._roles.indexOf('accountHandle'), 1); } }; AccountServiceModel.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); this._modelAdaptor.destroy(); backendDelegate.deleteId(this._id); }, // properties count: function(callback) { this._validate(); callback(this._object.count); }, service: function(callback) { this._validate(); callback(this._object.service); }, setService: function(service, callback) { this._validate(); this._object.service = service; if (callback) callback(); }, provider: function(callback) { this._validate(); callback(this._object.provider); }, setProvider: function(provider, callback) { this._validate(); this._object.provider = provider; if (callback) callback(); }, serviceType: function(callback) { this._validate(); callback(this._object.serviceType); }, setServiceType: function(serviceType, callback) { this._validate(); this._object.serviceType = serviceType; if (callback) callback(); }, includeDisabled: function(callback) { this._validate(); callback(this._object.includeDisabled); }, setIncludeDisabled: function(includeDisabled, callback) { this._validate(); this._object.includeDisabled = includeDisabled; if (callback) callback(); }, accountId: function(callback) { this._validate(); callback(this._object.accountId); }, setAccountId: function(accountId, callback) { this._validate(); this._object.accountId = accountId; if (callback) callback(); }, // QAbtractListModel prototype count: function(callback) { if (this._modelAdaptor) { callback(-1); } callback(this._modelAdaptor.rowCount()); }, at: function(idx, callback) { var count = this._modelAdaptor.rowCount(); if (idx >= count || ! this._modelAdaptor) { callback(null); return; } var result = {}; for (var role in this._roles) { result[role] = this._modelAdaptor.itemAt(idx, role); } callback(result); }, // Internal bits, not part of the API (especially no async) internal: { // special case for an object wrapper accountServiceAtIndex: function(self, idx) { self._validate(); var accountServiceHandle = self._modelAdaptor.itemAt(idx, "accountServiceHandle"); if (accountServiceHandle != null) { var accountService = new AccountService(); accountService.setObjectHandle(accountServiceHandle); return accountService; } return null; }, itemAt: function(self, idx, role) { self._validate(); return self._modelAdaptor.itemAt(idx, role); }, count: function(self) { return self._modelAdaptor ? self._modelAdaptor.rowCount() : -1; }, includeDisabled: function(self) { return self._object.includeDisabled; }, } }; function _constructorFromName(className) { var constructorPerName = { "AccountServiceModel": AccountServiceModel, "Account": Account, "ProviderModel": ProviderModel, "Manager": Manager, "AccountService": AccountService }; return className in constructorPerName ? constructorPerName[className] : null; }; return { createAccountServiceModel: function(callback) { var service = new AccountServiceModel(); callback(service.serialize()); }, createManager: function(callback) { var manager = new Manager(); callback(manager.serialize()); }, createProviderModel: function(callback) { var provider = new ProviderModel(); callback(provider.serialize()); }, // api getAccountsInfoFor: function(service, provider, callback) { var serviceModel = new AccountServiceModel({'service': service, 'provider': provider}); var count = serviceModel.internal.count(serviceModel); var accountsInfo = [] for (var i = 0; i < count; ++i) { var displayName = serviceModel.internal.itemAt(serviceModel, i, "displayName"); var accountId = serviceModel.internal.itemAt(serviceModel, i, "accountId"); var providerName = serviceModel.internal.itemAt(serviceModel, i, "providerName"); var serviceName = serviceModel.internal.itemAt(serviceModel, i, "serviceName"); var enabled = serviceModel.internal.itemAt(serviceModel, i, "enabled"); accountsInfo.push({displayName: displayName , accountId: accountId , providerName: providerName , serviceName: serviceName , enabled: enabled }); } serviceModel.destroy(); callback(accountsInfo); }, getAccounts: function(filters, callback) { var serviceModel = new AccountServiceModel(filters); var count = serviceModel.internal.count(serviceModel); var accounts = [] for (var i = 0; i < count; ++i) { var service = serviceModel.internal.accountServiceAtIndex(serviceModel, i); if (service) { var s = service.serialize(); console.debug(JSON.stringify(s.content)) accounts.push(s); } } callback(accounts); }, getAccountById: function(accountId, callback) { var manager = new Manager(); var account = manager.internal.loadAccount(manager, accountId); manager.destroy(); callback(account.serialize()); }, getAccessTokenFor: function(serviceName, providerName, accountId, callback) { var serviceModel = new AccountServiceModel(); if (serviceName) serviceModel.setService(serviceName); if (providerName) serviceModel.setProvider(providerName); if (accountId) serviceModel.setAccountId(accountId); var count = serviceModel.internal.count(serviceModel); if (count > 0) { var accountIdx = 0; if (count > 1) { console.debug("More than one account with id: " + accountId); } var onAuthenticated = function(results) { serviceModel.destroy(); callback(results); }; serviceModel.internal .accountServiceAtIndex(serviceModel, accountIdx) .authenticate(onAuthenticated); } else { serviceModel.destroy(); callback({error: "No account found"}); } }, // Internal dispatchToObject: function(infos) { var args = infos.args; var callback = infos.callback; var method_name = infos.method_name; var objectid = infos.objectid; var class_name = infos.class_name; if (callback) args.push(callback); var o = backendDelegate.objectFromId(objectid); if (o == null) { console.debug('Cannot dispatch to unknown object: ' + objectid); return; } var Constructor = _constructorFromName(class_name); var instance = new Constructor(o, objectid); instance[method_name].apply(instance, args); } }; } /** * * Alarm API backend binding * */ function createAlarmApi(backendDelegate) { var PLUGIN_URI = 'Ubuntu.Components'; var VERSION = 0.1; function _nameToAlarmType(name) { var alarmTypePerName = { "OneTime": ComponentsBridge.Alarm.OneTime, "Repeating": ComponentsBridge.Alarm.Repeating, }; return name in alarmTypePerName ? alarmTypePerName[name] : ComponentsBridge.Alarm.OneTime; }; function _alarmTypeToName(type) { if (type === ComponentsBridge.Alarm.OneTime) return "OneTime"; else if (type === ComponentsBridge.Alarm.Repeating) return "Repeating"; return ; }; function Alarm(alarm, objectid) { var id = objectid; if ( ! alarm) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'Alarm'); id = result.id; alarm = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(alarm, PLUGIN_URI, VERSION, 'Account'); } this._id = id; this._object = alarm; }; Alarm.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { return { type: 'object-proxy', apiid: 'Alarm', objecttype: 'Alarm', objectid: this._id, } }, // methods cancel: function() { this._validate(); this._object.cancel(); }, reset: function() { this._validate(); this._object.reset(); }, save: function() { this._validate(); this._object.save(); }, // properties error: function(callback) { this._validate(); callback(this._object.error); }, date: function(callback) { this._validate(); callback(this._object.date.getTime()); }, setDate: function(date, callback) { this._validate(); var _date = new Date(); _date.setTime(parseInt(date)); this._object.date = _date; if (callback && typeof(callback) === 'function') callback(); }, daysOfWeek: function(callback) { this._validate(); callback(this._object.daysOfWeek); }, setDaysOfWeek: function(daysOfWeek, callback) { this._validate(); this._object.daysOfWeek = daysOfWeek; if (callback && typeof(callback) === 'function') callback(); }, enabled: function(callback) { this._validate(); callback(this._object.enabled); }, setEnabled: function(enabled, callback) { this._validate(); this._object.enabled = enabled; if (callback && typeof(callback) === 'function') callback(); }, message: function(callback) { this._validate(); callback(this._object.message); }, setMessage: function(message, callback) { this._validate(); this._object.message = message; if (callback && typeof(callback) === 'function') callback(); }, sound: function(callback) { this._validate(); callback(this._object.sound); }, setSound: function(sound, callback) { this._validate(); this._object.sound = sound; if (callback && typeof(callback) === 'function') callback(); }, status: function(callback) { this._validate(); callback(this._object.status.toString()); }, type: function(callback) { this._validate(); callback(_alarmTypeToName(this._object.type)); }, setType: function(type, callback) { this._validate(); this._object.type = _nameToAlarmType(type); if (callback && typeof(callback) === 'function') callback(); }, // internal internal: { error: function(self) { return self._object.error; } } }; function _constructorFromName(className) { var constructorPerName = { "Alarm": Alarm, }; return className in constructorPerName ? constructorPerName[className] : null; } return { createAlarm: function(callback) { console.log('createAlarm') var alarm = new Alarm(); callback(alarm.serialize()); }, createAndSaveAlarmFor: function(date, type, daysOfWeek, message, callback) { var alarm = new Alarm(); alarm.setDate(date); alarm.setMessage(message); alarm.setType(_nameToAlarmType(type)); alarm.setDaysOfWeek(daysOfWeek); alarm.save(); if (callback && typeof(callback) === 'function') callback(alarm.internal.error(alarm)); alarm.destroy(); }, // Internal dispatchToObject: function(infos) { var args = infos.args; var callback = infos.callback; var method_name = infos.method_name; var objectid = infos.objectid; var class_name = infos.class_name; if (callback) args.push(callback); var o = backendDelegate.objectFromId(objectid); if (o == null) { console.debug('Cannot dispatch to unknown object: ' + objectid); return; } var Constructor = _constructorFromName(class_name); var instance = new Constructor(o, objectid); instance[method_name].apply(instance, args); } }; } /** * * ContentHub API backend binding * */ function createContentHubApi(backendDelegate) { var PLUGIN_URI = 'Ubuntu.Content'; var VERSION = 0.1; var _contenthub = ContentHubBridge.ContentHub; // TODO find a better way function _nameToContentType(name) { var contentTypePerName = { "All": ContentHubBridge.ContentType.All, "Unknown": ContentHubBridge.ContentType.Unknown, "Pictures": ContentHubBridge.ContentType.Pictures, "Documents": ContentHubBridge.ContentType.Documents, "Music": ContentHubBridge.ContentType.Music, "Contacts": ContentHubBridge.ContentType.Contacts, }; return name in contentTypePerName ? contentTypePerName[name] : ContentHubBridge.ContentType.Unknown; }; function _contentTypeToName(state) { if (state === ContentHubBridge.ContentType.All) return "All"; else if (state === ContentHubBridge.ContentType.Unknown) return "Unknown"; else if (state === ContentHubBridge.ContentType.Pictures) return "Pictures"; else if (state === ContentHubBridge.ContentType.Documents) return "Documents"; else if (state === ContentHubBridge.ContentType.Music) return "Music"; else if (state === ContentHubBridge.ContentType.Contacts) return "Contacts"; return "Unknown"; }; function _nameToContentTransferSelection(name) { var contentTypePerName = { "Single": ContentHubBridge.ContentTransfer.Single, "Multiple": ContentHubBridge.ContentTransfer.Multiple, }; return name in contentTypePerName ? contentTypePerName[name] : ContentHubBridge.ContentTransfer.Single; }; function _contentTransferSelectionToName(state) { if (state === ContentHubBridge.ContentTransfer.Single) return "Single"; else if (state === ContentHubBridge.ContentTransfer.Multiple) return "Multiple"; return "Single"; }; function _nameToContentHandler(name) { var contentHandlerPerName = { "Source": ContentHubBridge.ContentHandler.Source, "Destination": ContentHubBridge.ContentHandler.Destination, "Share": ContentHubBridge.ContentHandler.Share, }; return name in contentHandlerPerName ? contentHandlerPerName[name] : ContentHubBridge.ContentHandler.Source; }; function _contentHandlerToName(state) { if (state === ContentHubBridge.ContentHandler.Source) return "Source"; else if (state === ContentHubBridge.ContentHandler.Destination) return "Destination"; else if (state === ContentHubBridge.ContentHandler.Share) return "Share"; return "Source"; }; function _nameToContentTransferDirection(name) { var contentTypePerName = { "Import": ContentHubBridge.ContentTransfer.Import, "Export": ContentHubBridge.ContentTransfer.Export, "Share": ContentHubBridge.ContentTransfer.Share, }; return name in contentTypePerName ? contentTypePerName[name] : ContentHubBridge.ContentTransfer.Import; }; function _contentTransferDirectionToName(state) { if (state === ContentHubBridge.ContentTransfer.Import) return "Import"; else if (state === ContentHubBridge.ContentTransfer.Export) return "Export"; else if (state === ContentHubBridge.ContentTransfer.Share) return "Share"; return "Import"; }; function _nameToContentScope(name) { var contentScopePerName = { "System": ContentHubBridge.ContentScope.System, "User": ContentHubBridge.ContentScope.User, "App": ContentHubBridge.ContentScope.App, }; return name in contentScopePerName ? contentScopePerName[name] : ContentHubBridge.ContentScope.App; }; function _contentScopeToName(state) { if (state === ContentHubBridge.ContentScope.System) return "System"; else if (state === ContentHubBridge.ContentScope.User) return "User"; else if (state === ContentHubBridge.ContentScope.App) return "App"; return "App"; }; function _nameToContentTransferState(name) { var contentTransferStatePerName = { "Created": ContentHubBridge.ContentTransfer.Created, "Initiated": ContentHubBridge.ContentTransfer.Initiated, "InProgress": ContentHubBridge.ContentTransfer.InProgress, "Charged": ContentHubBridge.ContentTransfer.Charged, "Collected": ContentHubBridge.ContentTransfer.Collected, "Aborted": ContentHubBridge.ContentTransfer.Aborted, "Finalized": ContentHubBridge.ContentTransfer.Finalized, }; return name in contentTransferStatePerName ? contentTransferStatePerName[name] : ContentHubBridge.ContentTransfer.Created; }; function _contentTransferStateToName(state) { if (state === ContentHubBridge.ContentTransfer.Created) return "Created"; else if (state === ContentHubBridge.ContentTransfer.Initiated) return "Initiated"; else if (state === ContentHubBridge.ContentTransfer.InProgress) return "InProgress"; else if (state === ContentHubBridge.ContentTransfer.Charged) return "Charged"; else if (state === ContentHubBridge.ContentTransfer.Collected) return "Collected"; else if (state === ContentHubBridge.ContentTransfer.Aborted) return "Aborted"; else if (state === ContentHubBridge.ContentTransfer.Finalized) return "Finalized"; return ""; }; function ContentTransfer(transfer, objectid) { var id = objectid; if ( ! transfer) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentTransfer'); id = result.id; transfer = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(transfer, PLUGIN_URI, VERSION, 'ContentTransfer'); } this._id = id; this._object = transfer; this._callback = null; }; ContentTransfer.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentTransfer', objectid: self._id, // serialize immutable values content: { store: self._object.store, state: self._object.state, selectionType: self._object.selectionType, direction: self._object.direction, } } }, // properties store: function(callback) { this._validate(); callback(this._object.store); }, setStore: function(storeProxy, callback) { this._validate(); if (backendDelegate.isObjectProxyInfo(storeProxy)) { var store = backendDelegate.objectFromId(storeProxy.objectid); if (store) this._object.setStore(store); } else { console.debug('setStore: invalid store object proxy'); } if (callback) callback(); }, state: function(callback) { this._validate(); callback(_contentTransferStateToName(this._object.state)); }, setState: function(state, callback) { this._validate(); this._object.state = _nameToContentTransferState(state); if (callback && typeof(callback) === 'function') callback(); }, onStateChanged: function(callback) { if (!callback || typeof(callback) !== 'function') return; this._validate(); var self = this; this._object.onStateChanged.connect(function() { callback(_contentTransferStateToName(self._object.state)); }); }, selectionType: function(callback) { this._validate(); callback(_contentTransferSelectionToName(this._object.selectionType)); }, setSelectionType: function(selectionType, callback) { this._validate(); this._object.selectionType = _nameToContentTransferSelection(selectionType); if (callback && typeof(callback) === 'function') callback(); }, direction: function(callback) { this._validate(); callback(_contentTransferDirectionToName(this._object.direction)); }, setDirection: function(direction, callback) { this._validate(); this._object.direction = _nameToContentTransferDirection(direction); if (callback && typeof(callback) === 'function') callback(); }, items: function(callback) { this._validate(); // return in serialized form callback(this.internal.serializeItems(this._object)); }, setItems: function(items, callback) { this._validate(); var contentItems = []; for (var i = 0; i < items.length; ++i) { var item = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentItem'); if ( ! item.object) { console.debug('Could not create ContentItem object'); continue; } item.object.name = items[i].name; item.object.url = items[i].url; contentItems.push(item.object); } this._object.items = contentItems; if (callback && typeof(callback) === 'function') callback(); }, // methods start: function(callback) { this._validate(); var self = this; this._callback = function () { callback(_contentTransferStateToName(self._object.state)); }; this._object.stateChanged.connect(this._callback); this._object.start(); }, finalize: function() { this._validate(); if (this._callback) this._object.stateChanged.disconnect(this._callback); this._callback = null; this._object.finalize(); }, // internal internal: { serializeItems: function(self) { var items = []; for (var i = 0; i < self.items.length; ++i) { items.push({name: self.items[i].name.toString(), url: self.items[i].url.toString()}); } return items; } } }; function ContentStore(store, objectid) { var id = objectid; if ( ! store) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentStore'); id = result.id; store = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(store, PLUGIN_URI, VERSION, 'ContentStore'); } this._id = id; this._object = store; }; ContentStore.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentStore', objectid: this._id, // serialize immutable values content: { uri: self._object.uri, scope: _contentScopeToName(self._object.scope), } } }, // properties scope: function(callback) { this._validate(); callback(_contentScopeToName(this._object.scope)); }, setScope: function(scope, callback) { this._validate(); this._object.scope = _nameToContentScope(scope); if (callback && typeof(callback) === 'function') callback(); }, //immutable uri: function(callback) { this._validate(); callback(this._object.uri); }, }; function ContentPeer(peer, objectid) { var id = objectid; if ( ! peer) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentPeer'); id = result.id; peer = result.object; } if ( ! id) { id = backendDelegate.storeQmlObject(peer, PLUGIN_URI, VERSION, 'ContentPeer'); } this._id = id; this._object = peer; }; ContentPeer.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); backendDelegate.deleteId(this._id); }, // object methods serialize: function() { var self = this; return { type: 'object-proxy', apiid: 'ContentHub', objecttype: 'ContentPeer', objectid: self._id, // serialize immutable values content: { appId: self._object.appId, name: self._object.name, handler: self._object.handler, contentType: self._object.contentType, selectionType: self._object.selectionType, isDefaultPeer: self._object.isDefaultPeer, }, } }, // properties appId: function(callback) { this._validate(); callback(this._object.appId); }, setAppId: function(appId, callback) { this._validate(); this._object.appId = appId; if (callback && typeof(callback) === 'function') callback(); }, handler: function(callback) { this._validate(); callback(_contentHandlerToName(this._object.handler)); }, setHandler: function(handler, callback) { this._validate(); this._object.handler = _nameToContentHandler(handler); if (callback && typeof(callback) === 'function') callback(); }, contentType: function(callback) { this._validate(); callback(_contentTypeToName(this._object.contentType)); }, setContentType: function(contentType, callback) { this._validate(); this._object.contentType = _nameToContentType(contentType); if (callback && typeof(callback) === 'function') callback(); }, selectionType: function(callback) { this._validate(); callback(_contentTransferSelectionToName(this._object.selectionType)); }, setSelectionType: function(selectionType, callback) { this._validate(); this._object.selectionType = _nameToContentTransferSelection(selectionType); if (callback && typeof(callback) === 'function') callback(); }, // immutable name: function(callback) { this._validate(); callback(this._object.name); }, isDefaultPeer: function(callback) { this._validate(); callback(this._object.isDefaultPeer); }, // methods request: function(callback) { this._validate(); var transfer = new ContentTransfer(this._object.request()); if (callback && typeof(callback) === 'function') callback(transfer.serialize()); }, requestForStore: function(store, callback) { if ( ! store) { callback(null); return; } if (! backendDelegate.isObjectProxyInfo(store)) { console.debug('requestForStore: invalid store object proxy') callback("Invalid store"); return; } var _store = backendDelegate.objectFromId(store.objectid); if ( ! _store) { callback("Invalid store object (NULL)"); return; } this._validate(); var transfer = new ContentTransfer(this._object.request(_store)); if (callback && typeof(callback) === 'function') callback(transfer.serialize()); }, // internal internal: { request: function(self) { return self._object.request(); } } }; function ContentPeerModel(filterParams) { var result = backendDelegate.createQmlObject( PLUGIN_URI, VERSION, 'ContentPeerModel', filterParams); this._id = result.id; this._object = result.object; this._modelAdaptor = backendDelegate.createModelAdaptorFor(this._object); this._roles = this._modelAdaptor.roles(); }; ContentPeerModel.prototype = { _validate: function() { if (! this._object) throw new TypeError("Invalid object null"); }, destroy: function() { if (! this._object) return; this._object.destroy(); this._modelAdaptor.destroy(); backendDelegate.deleteId(this._id); }, // properties setContentType: function(contentType, callback) { this._validate(); this._object.contentType = contentType; if (callback) callback(); }, setHandler: function(handler, callback) { this._validate(); this._object.handler = handler; if (callback) callback(); }, peers: function() { this._validate(); return this._object.peers; }, // QAbtractListModel prototype count: function(callback) { if (!this._modelAdaptor) { callback(-1); return; } callback(this._modelAdaptor.rowCount()); }, }; function _constructorFromName(className) { var constructorPerName = { "ContentPeer": ContentPeer, "ContentStore": ContentStore, "ContentTransfer": ContentTransfer, }; return className in constructorPerName ? constructorPerName[className] : null; } return { getPeers: function(filters, callback) { if ( ! filters){ callback(null); return; } var statement = "import QtQuick 2.0; import Ubuntu.Content 0.1; ContentPeerModel {"; var filterParams = {}; if (filters.contentType) { statement += " contentType: ContentType." + filters.contentType + ";"; } if (filters.handler) { statement += " handler: ContentHandler." + filters.handler + ";"; } statement += " }"; var peerModel = Qt.createQmlObject(statement, backendDelegate.parent()); var onPeersFound = function() { var peers = peerModel.peers; var wrappedPeers = []; for (var i = 0; i < peers.length; ++i) { var wrappedPeer = new ContentPeer(peers[i]); wrappedPeers.push(wrappedPeer.serialize()); } peerModel.onFindPeersCompleted.disconnect(onPeersFound); callback(wrappedPeers); }; peerModel.onFindPeersCompleted.connect(onPeersFound); }, getStore: function(scope, callback) { if ( ! scope){ callback(null); return; } var store = new ContentStore(); store.setScope(scope); callback(store.serialize()); }, launchContentPeerPicker: function(filters, onPeerSelected, onCancelPressed) { if ( ! filters){ callback(null); return; } var parentItem = backendDelegate.parentView(); if ( ! parentItem || ! parentItem.visible || ! parentItem.height || ! parentItem.width) { console.debug("Cannot launch the content peer picker UI, invalid parent item: " + parentItem); onCancelPressed(); return; } var statement = "import QtQuick 2.0; import Ubuntu.Content 0.1; ContentPeerPicker {"; var filterParams = {}; if (filters.contentType) { statement += " contentType: ContentType." + filters.contentType + ""; } if (filters.handler) { statement += "; handler: ContentHandler." + filters.handler + ""; } if (filters.showTitle) { statement += "; showTitle: " + filters.showTitle === false ? "false" : "true"; } statement += "; visible: true; }"; if (parentItem.parent) parentItem.visible = false; var contentPeerPicker = Qt.createQmlObject(statement, parentItem.parent ? parentItem.parent : parentItem); function _onPeerSelected() { var peer = new ContentPeer(contentPeerPicker.peer); contentPeerPicker.visible = false; parentItem.visible = true; onPeerSelected(peer.serialize()); contentPeerPicker.onPeerSelected.disconnect(_onPeerSelected); contentPeerPicker.destroy(); } function _onCancelPressed() { contentPeerPicker.visible = false; parentItem.visible = true; onCancelPressed(); contentPeerPicker.onPeerSelected.disconnect(_onCancelPressed); contentPeerPicker.destroy(); } contentPeerPicker.onPeerSelected.connect(_onPeerSelected); contentPeerPicker.onCancelPressed.connect(_onCancelPressed); }, apiImportContent: function(type, peer, transferOptions, onSuccess, onFailure) { if (! backendDelegate.isObjectProxyInfo(peer)) { console.debug('apiImportContent: invalid peer object proxy') onError("Invalid peer"); return; } var _type = _nameToContentType(type); var _peer = backendDelegate.objectFromId(peer.objectid); if ( ! _peer) { onError("Invalid peer object (NULL)"); return; } var _transfer = null; if (transferOptions.scope) { var store = new ContentStore(); store.setScope(transferOptions.scope); _transfer = _peer.request(store._object); } else { _transfer = _peer.request(); } if (transferOptions.multipleFiles) { _transfer.selectionType = ContentHubBridge.ContentTransfer.Multiple; } else { _transfer.selectionType = ContentHubBridge.ContentTransfer.Single; } var transfer = new ContentTransfer(_transfer) _transfer.stateChanged.connect(function() { if (_transfer.state === ContentHubBridge.ContentTransfer.Aborted) { onFailure("Aborted"); return; } else if (_transfer.state === ContentHubBridge.ContentTransfer.Charged) { var d = transfer.internal.serializeItems(_transfer); onSuccess(d); _transfer.finalize(); return; } }); _transfer.start(); }, onExportRequested: function(callback) { _contenthub.exportRequested.connect(function(exportTransfer) { var wrapped = new ContentTransfer(exportTransfer); callback(wrapped.serialize()); }); }, // Internal dispatchToObject: function(infos) { var args = infos.args; var callback = infos.callback; var method_name = infos.method_name; var objectid = infos.objectid; var class_name = infos.class_name; if (callback) args.push(callback); var o = backendDelegate.objectFromId(objectid); if (o == null) { console.debug('Cannot dispatch to unknown object: ' + objectid); return; } var Constructor = _constructorFromName(class_name); var instance = new Constructor(o, objectid); instance[method_name].apply(instance, args); } }; } unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/0000755000015301777760000000000012320723226025302 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/js/0000755000015301777760000000000012320723226025716 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/js/api-sanitizer.js0000644000015301777760000001043012320722666031040 0ustar pbusernogroup00000000000000function checkString(str, allowUndef) { if (allowUndef && str == undefined) { return; } if (!str || typeof(str) !== 'string') { throw new TypeError("incorrect argument"); } } function stringify(obj) { if (obj === undefined) return obj; if (obj === null) return obj; if (typeof(obj) == 'string') return obj; if (typeof(obj) == 'number') return obj; if (typeof(obj) == 'function') return String(obj); var dump = {}; for (var i in obj) { if (obj.hasOwnProperty(i)) dump[i] = stringify(obj[i]); } return dump; }; function stringifyArgs(obj) { var args = []; for (var i = 0; i < obj.length; i++) { args.push(stringify(obj[i])); } var res = JSON.stringify(args); return res.substr(1, res.length - 2); }; function createArgumentsSanitizer(backend, argsDesc, function_name) { var callback = function() { var args = []; args.push(function_name); args.push([].slice.call(arguments)); backend.call.apply(backend, args); }; return function () { var realArgs = arguments; var k = 0; function argumentSanitizer(desc, arg) { if (!desc) { throw new Error("argument description is null"); } if (desc.dummy) { k--; return null; } if (desc.array) { if (!(desc.array instanceof Object) || !(desc.array.element instanceof Object)) { throw new Error("invalid argument description"); } try { for (var j = 0; j < arg.length; j++) { argumentSanitizer(desc.array.element, arg[j]); } } catch (x) { throw new TypeError("incorrect argument"); } return arg; } if (desc.obj) { if (!(desc.obj instanceof Object)) { throw new InternalError("invalid argument description"); } var res = {}, i; for (i in desc.obj) { if (desc.obj.hasOwnProperty(i)) { res[i] = argumentSanitizer(desc.obj[i], arg[i]); } } return res; } if (desc.str) { if (desc.allowNull && !arg) { return null; } checkString(arg, false); return arg; } if (desc.number) { if (typeof(arg) !== 'number' && typeof(arg) !== 'boolean') throw new TypeError("incorrect argument"); return arg; } if (!desc.type) { throw new Error("argument description miss required parameter"); } if ((arg instanceof desc.type) || (desc.type === Function && ((typeof arg) === 'function')) || (arg === null && desc.allowNull)) { if (desc.type === Function) { if (!arg) { return null; } var id; if (desc.argAsCallbackId !== undefined) { id = realArgs[desc.argAsCallbackId]; } return function (user_data) { arg(user_data); }; } return arg; } else { throw new TypeError("incorrect argument"); } throw new Error("unreacheable"); } var args = [], i; for (i = 0; i < argsDesc.length; i++) { if (k >= realArgs.length && k > 0 && !argsDesc[i].dummy) { throw new Error("not enough arguments"); } var value = argumentSanitizer(argsDesc[i], realArgs[k]); k++; if (argsDesc[i].obj) { args = args.concat(value); } else { args.push(value); } } if (k < realArgs.length) { throw new Error("too much arguments"); } callback.apply(null, args); return null; }; }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/js/unity-binding-proxy.js0000644000015301777760000000070212320722666032221 0ustar pbusernogroup00000000000000function UnityBindingProxy(backend, id, api_data) { this._backend = backend; this._id = id; this._api_data = api_data; } UnityBindingProxy.prototype = { call: function(method_name, params, callback) { this._backend.callObjectMethod( this._id, this._api_data, method_name, params, callback); }, id: function(name, params) { return this._id; }, }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/js/unity-binding-bridge.js0000644000015301777760000001513412320722666032301 0ustar pbusernogroup00000000000000function UnityBindingBridge(callbackManager, backendMessagingProxy) { this._proxies = {}; this._last_proxy = 0; this._callbackManager = callbackManager; this._bindingApi = null; this._backendMessagingProxy = backendMessagingProxy; this._startMessagePump(); }; UnityBindingBridge.prototype = { /** * Calls a plain raw API function. * * @method call * @param */ call: function(method_name, args, callback) { var self = this; var _args = JSON.stringify(args.map (function (arg) { return self._transformCallbacksToIds(arg); })); this._sendToBackend( JSON.stringify({target: "ubuntu-webapps-binding-call", name: method_name, args: _args, callback: callback ? this._transformCallbacksToIds(callback) : null})); }, /** * * * @method setBindingApi * @param */ setBindingApi: function(bindingApi) { this._bindingApi = bindingApi; }, /** * * * @method isObjectProxyInfo * @param */ isObjectProxyInfo: function(info) { return 'type' in info && info.type === 'object-proxy' && 'apiid' in info && 'objecttype' in info && 'objectid' in info; }, /** * * * @method * @param */ createRemoteObject: function(plugin_uri, class_name, objectid) { var id = objectid ? objectid : this._generateProxyIdFor(plugin_uri, class_name); return new UnityBindingProxy(this, id, {uri: plugin_uri, class_name: class_name}); }, /** * @method * @param */ callObjectMethod: function(objectid, api_data, method_name, params, callback) { params = params || []; var self = this; var args = JSON.stringify(params.map ( function (param) { return self._transformCallbacksToIds(param); })); this._sendToBackend( JSON.stringify({target: "ubuntu-webapps-binding-call-object-method", objectid: objectid, name: method_name, api_uri: api_data.uri, class_name: api_data.class_name, args: args, callback: callback ? this._transformCallbacksToIds(callback) : null})); }, /** * @internal */ _generateProxyIdFor: function(uri, object_name) { var candidate = uri + object_name + this._last_proxy_id; while (this._proxies[candidate] != undefined) { ++this._last_proxy_id; candidate = uri + object_name + this._last_proxy_id; } return candidate; }, /** * @internal */ _startMessagePump: function() { var self = this; this._backendMessagingProxy.addMessageHandler(function (message) { if (isUbuntuBindingCallbackCall (message)) { try { self._dispatchCallbackCall (message.id, message.args); } catch(e) { console.log('Error while dispatching callback call: ' + e) } } else { try { console.log('Unknown message received: ' + JSON.stringify(message)); } catch(e) {} } }); }, /** * @internal */ _dispatchCallbackCall: function(id, args) { if (! id || ! args) return; var cbfunc = this._callbackManager.get(id); if (!cbfunc || !(cbfunc instanceof Function)) { try { console.log('Invalid callback id: ' + id); } catch (e) {} return; } // actual callback call var targs = this._translateArgs(args); cbfunc.apply(null, targs); }, /** * @internal */ _translateArgs: function(args) { var _args = args || []; var self = this; _args = _args.map(function(arg) { if (isUbuntuBindingObjectProxy(arg)) { var narg = self._wrapObjectProxy(arg.apiid, arg.objecttype, arg.objectid, arg.content); return narg; } else if (arg instanceof Array) { return self._translateArgs(arg); } return arg; }); return _args; }, /** * @internal */ _wrapObjectProxy: function(apiId, objectType, objectId, content) { if (this._bindingApi && this._bindingApi[apiId] != null) { var wrapper = this._bindingApi[apiId] .createObjectWrapper(objectType, objectId, content); return wrapper; } return null; }, /** * @internal */ _sendToBackend: function(data) { this._backendMessagingProxy.postMessage(data); }, /** * @internal */ _transformToIdIfNecessary: function(obj) { var ret = obj; if (obj instanceof Function) { var id = this._callbackManager.store(obj); ret = {callbackid: id}; } return ret; }, /** * @internal */ _transformCallbacksToIds: function(obj) { var self = this; if ( ! isIterableObject(obj)) { return self._transformToIdIfNecessary (obj); } var ret = (obj instanceof Array) ? [] : {}; for (var key in obj) { if (obj.hasOwnProperty(key)) { if (obj[key] instanceof Function) { var id = self._callbackManager.store(obj[key]); ret[key] = {callbackid: id}; } else if (isIterableObject (obj[key])) { ret[key] = self._transformCallbacksToIds (obj[key]); } else { ret[key] = obj[key]; } } } // for (var key return ret; }, }; ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.jsunity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy0000644000015301777760000000247112320722666033543 0ustar pbusernogroup00000000000000function createMessagingProxyForCurrentWebRuntime() { if (navigator && navigator.qt && navigator.qt.postMessage) { return new UnityQtWebkitBackendMessagingProxy(); } else if (window.oxide) { return new UnityOxideBackendMessagingProxy(); } return null; } function UnityOxideBackendMessagingProxy() { } UnityOxideBackendMessagingProxy.prototype = { postMessage: function(content) { // a little bit of a dup from whats in UnityWebAppsUtils.js var message = JSON.parse(content); oxide.sendMessage("UnityWebappApi-Message", message) }, addMessageHandler: function(callback) { // a little bit of a dup from whats in UnityWebAppsUtils.js oxide.addMessageHandler("UnityWebappApi-Host-Message", function(content) { callback(content.args); }); }, }; function UnityQtWebkitBackendMessagingProxy() { } UnityQtWebkitBackendMessagingProxy.prototype = { postMessage: function(content) { navigator.qt.postMessage(content); }, addMessageHandler: function(callback) { if (callback && typeof callback === 'function') navigator.qt.onmessage = function(message) { var content = JSON.parse(message.data); callback(content); }; }, }; unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/UnityWebApps/unity-webapps-api.js.in0000644000015301777760000002546212320722666030353 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of unity-webapps-qml. * * unity-webapps-qml is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * unity-webapps-qml 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 . */ (function () { if (window.self !== window.top) { return; } // Acknowledge that the API has been fully injected var sendApiCreatedAcknowledgeEvent = function () { var e = document.createEvent ("Events"); e.initEvent ("ubuntu-webapps-api-ready", false, false); document.dispatchEvent (e); }; //@include UnityWebAppsUtils.js //@include ./bindings/alarm-api/client/alarm-api.js //@include ./bindings/content-hub/client/content-hub.js //@include ./bindings/online-accounts/client/online-accounts.js //@include ./bindings/runtime-api/client/runtime-api.js //@include ./common/js/unity-backend-messaging-proxy.js //@include ./common/js/unity-binding-proxy.js //@include ./common/js/unity-binding-bridge.js var apiBuilder = function(backend) { //@include ./common/js/api-sanitizer.js var api = { init: function(props) { checkString(props.name, false); checkString(props.iconUrl, true); checkString(props.domain, true); checkString(props.login, true); checkString(props.mimeTypes, true); checkString(props.homepage, true); if (props.homepage && !/^(http|https|file):\/\//.test(props.homepage)) { throw new TypeError("incorrect argument"); } if (window.location.protocol !== 'file:') props.__unity_webapps_hidden = { hostname: window.location.hostname, url: window.location.href }; else props.__unity_webapps_hidden = {local: true}; backend.call("init", [props]); }, /** * * @method acceptData * @param mimeType {String} * @param callback {Function} */ acceptData: createArgumentsSanitizer (backend, [{ array: { element: { str: true } } }, { type: Function, js: true }], 'acceptData'), /** * * @param name {String} * @param callback {Function} */ addAction: createArgumentsSanitizer (backend, [{ str: true }, { type: Function, argAsCallbackId: 0 }] , 'addAction'), /** * * @param name {String} */ clearAction: createArgumentsSanitizer (backend, [{ str: true }], 'clearAction'), /** * */ clearActions: createArgumentsSanitizer (backend, [], 'clearActions'), /** * * MediaPlayer API * */ MediaPlayer: { init: function() {}, /** * * @param callback {Function} */ onPlayPause: createArgumentsSanitizer (backend, [{ type: Function, allowNull: true }, { dummy: true }] , 'MediaPlayer.onPlayPause'), /** * * @param callback {Function} */ onPrevious: createArgumentsSanitizer (backend, [{ type: Function, allowNull: true }, { dummy: true }] , 'MediaPlayer.onPrevious'), /** * * @param callback {Function} */ onNext: createArgumentsSanitizer (backend, [{ type: Function, allowNull: true }, { dummy: true }] , 'MediaPlayer.onNext'), /** * * @param callback {Function} */ setTrack: createArgumentsSanitizer(backend, [{ obj: { artist: { str: true, place: 0, allowNull: true }, album: { str: true, place: 1, allowNull: true }, title: { str: true, place: 2 }, artLocation: { str: true, place: 3, allowNull: true } } }] , 'MediaPlayer.setTrack'), /** * * @param callback {Function} */ setCanGoNext: createArgumentsSanitizer (backend, [{ number: true }], 'MediaPlayer.setCanGoNext'), /** * * @param callback {Function} */ setCanGoPrevious: createArgumentsSanitizer (backend, [{ number: true }], 'MediaPlayer.setCanGoPrevious'), /** * * @param callback {Function} */ setCanPlay: createArgumentsSanitizer (backend, [{ number: true }], 'MediaPlayer.setCanPlay'), /** * * @param callback {Function} */ setCanPause: createArgumentsSanitizer (backend, [{ number: true }], 'MediaPlayer.setCanPause'), /** * * @param callback {Function} */ setPlaybackState: createArgumentsSanitizer (backend, [{ number: true }], 'MediaPlayer.setPlaybackState'), /** * * @param callback {Function} */ getPlaybackState: createArgumentsSanitizer (backend, [{ type: Function }], 'MediaPlayer.getPlaybackState'), PlaybackState: {PLAYING: 0, PAUSED:1}, /** * @private */ __get: createArgumentsSanitizer(backend, [{ str: true }, { type: Function, argAsCallbackId: 0 }], 'MediaPlayer.__get') }, Notification: { /** * * @param callback {Function} */ showNotification: createArgumentsSanitizer (backend, [{ str: true }, { str: true }, { str: true, allowNull: true }] , 'Notification.showNotification') }, Launcher: { /** * * @param callback {Function} */ setCount: createArgumentsSanitizer (backend, [{ number: true }], 'Launcher.setCount'), /** * * @param callback {Function} */ clearCount: createArgumentsSanitizer (backend, [], 'Launcher.clearCount'), /** * * @param callback {Function} */ setProgress: createArgumentsSanitizer (backend, [{ number: true }], 'Launcher.setProgress'), /** * * @param callback {Function} */ clearProgress: createArgumentsSanitizer (backend, [], 'Launcher.clearProgress'), /** * * @param callback {Function} */ setUrgent: createArgumentsSanitizer (backend, [], 'Launcher.setUrgent'), /** * * @param callback {Function} */ addAction: function(arg1, arg2) { if (typeof(arg2) === 'string') backend.call('Launcher.addStaticAction', [arg1, arg2]); else backend.call('Launcher.addAction', [arg1, arg2]); }, /** * * @param callback {Function} */ removeAction: createArgumentsSanitizer (backend, [{ str: true }], 'Launcher.removeAction'), /** * * @private */ removeActions: createArgumentsSanitizer (backend, [], 'Launcher.removeActions'), /** * * @private */ __get: createArgumentsSanitizer (backend, [{ str: true }, { type: Function, argAsCallbackId: 0 }] , 'Launcher.__get') }, MessagingIndicator: { /** * * @private */ addAction: createArgumentsSanitizer (backend, [{ str: true }, { type: Function, argAsCallbackId: 0 }, { dummy: true }] , 'MessagingIndicator.addAction'), /** * * @private */ showIndicator: function(name, properties) { backend.call('MessagingIndicator.showIndicator', [name, properties]); }, /** * * @private */ clearIndicator: createArgumentsSanitizer (backend, [{ str: true }], 'MessagingIndicator.clearIndicator'), /** * * @private */ clearIndicators: createArgumentsSanitizer (backend, [], 'MessagingIndicator.clearIndicators'), }, OnlineAccounts: createOnlineAccountsApi(backend), AlarmApi: createAlarmApi(backend), ContentHub: createContentHubApi(backend), RuntimeApi: createRuntimeApi(backend), }; return api; }; var apiBridge = new UnityBindingBridge(makeCallbackManager(), createMessagingProxyForCurrentWebRuntime()); var api = apiBuilder (apiBridge); apiBridge.setBindingApi(api); if (!window.external) window.external = {}; window.external.getUnityObject = function (version) { return api; }; sendApiCreatedAcknowledgeEvent(); unsafeWindow = window; }) (); unity-webapps-qml-0.1+14.04.20140408/src/Ubuntu/Ubuntu.pro0000644000015301777760000000005212320722666023430 0ustar pbusernogroup00000000000000TEMPLATE = subdirs SUBDIRS = UnityWebApps unity-webapps-qml-0.1+14.04.20140408/src/src.pro0000644000015301777760000000014712320722666021460 0ustar pbusernogroup00000000000000include(../common-project-config.pri) include(../common-vars.pri) TEMPLATE = subdirs SUBDIRS = Ubuntu unity-webapps-qml-0.1+14.04.20140408/docs/0000755000015301777760000000000012320723226020277 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/docs/qtquick.css0000644000015301777760000003175112320722666022510 0ustar pbusernogroup00000000000000@media screen { /* basic elements */ html { color: #000000; background: #FFFFFF; } table { border-collapse: collapse; border-spacing: 0; } fieldset, img { border: 0; max-width:100%; } address, caption, cite, code, dfn, em, strong, th, var, optgroup { font-style: inherit; font-weight: inherit; } del, ins { text-decoration: none; } ol li { list-style: decimal; } ul li { list-style: none; } caption, th { text-align: left; } h1.title { font-weight: bold; font-size: 150%; } h0 { font-weight: bold; font-size: 130%; } h1, h2, h3, h4, h5, h6 { font-size: 100%; } q:before, q:after { content: ''; } abbr, acronym { border: 0; font-variant: normal; } sup, sub { vertical-align: baseline; } tt, .qmlreadonly span, .qmldefault span { word-spacing:0.5em; } legend { color: #000000; } strong { font-weight: bold; } em { font-style: italic; } body { margin: 0 1.5em 0 1.5em; font-family: ubuntu; line-height: normal } a { color: #00732F; text-decoration: none; } hr { background-color: #E6E6E6; border: 1px solid #E6E6E6; height: 1px; width: 100%; text-align: left; margin: 1.5em 0 1.5em 0; } pre { border: 1px solid #DDDDDD; -moz-border-radius: 0.7em 0.7em 0.7em 0.7em; -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em; border-radius: 0.7em 0.7em 0.7em 0.7em; padding: 1em 1em 1em 1em; overflow-x: auto; } table, pre { -moz-border-radius: 0.7em 0.7em 0.7em 0.7em; -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em; border-radius: 0.7em 0.7em 0.7em 0.7em; background-color: #F6F6F6; border: 1px solid #E6E6E6; border-collapse: separate; margin-bottom: 2.5em; } pre { font-size: 90%; display: block; overflow:hidden; } thead { margin-top: 0.5em; font-weight: bold } th { padding: 0.5em 1.5em 0.5em 1em; background-color: #E1E1E1; border-left: 1px solid #E6E6E6; } td { padding: 0.25em 1.5em 0.25em 1em; } td.rightAlign { padding: 0.25em 0.5em 0.25em 1em; } table tr.odd { border-left: 1px solid #E6E6E6; background-color: #F6F6F6; color: black; } table tr.even { border-left: 1px solid #E6E6E6; background-color: #ffffff; color: #202020; } div.float-left { float: left; margin-right: 2em } div.float-right { float: right; margin-left: 2em } span.comment { color: #008B00; } span.string, span.char { color: #000084; } span.number { color: #a46200; } span.operator { color: #202020; } span.keyword { color: #840000; } span.name { color: black } span.type { font-weight: bold } span.type a:visited { color: #0F5300; } span.preprocessor { color: #404040 } /* end basic elements */ /* font style elements */ .heading { font-weight: bold; font-size: 125%; } .subtitle { font-size: 110% } .small-subtitle { font-size: 100% } .red { color:red; } /* end font style elements */ /* global settings*/ .header, .footer { display: block; clear: both; overflow: hidden; } /* end global settings*/ /* header elements */ .header .qtref { color: #00732F; font-weight: bold; font-size: 130%; } .header .content { margin-left: 5px; margin-top: 5px; margin-bottom: 0.5em; } .header .breadcrumb { font-size: 90%; padding: 0.5em 0 0.5em 1em; margin: 0; background-color: #fafafa; height: 1.35em; border-bottom: 1px solid #d1d1d1; } .header .breadcrumb ul { margin: 0; padding: 0; } .header .content { word-wrap: break-word; } .header .breadcrumb ul li { float: left; background: url(../images/breadcrumb.png) no-repeat 0 3px; padding-left: 1.5em; margin-left: 1.5em; } .header .breadcrumb ul li.last { font-weight: normal; } .header .breadcrumb ul li a { color: #00732F; } .header .breadcrumb ul li.first { background-image: none; padding-left: 0; margin-left: 0; } .header .content ol li { background: none; margin-bottom: 1.0em; margin-left: 1.2em; padding-left: 0 } .header .content li { background: url(../images/bullet_sq.png) no-repeat 0 5px; margin-bottom: 1em; padding-left: 1.2em; } /* end header elements */ /* content elements */ .content h1 { font-weight: bold; font-size: 130% } .content h2 { font-weight: bold; font-size: 120%; width: 100%; } .content h3 { font-weight: bold; font-size: 110%; width: 100%; } .content table p { margin: 0 } .content ul { padding-left: 2.5em; } .content li { padding-top: 0.25em; padding-bottom: 0.25em; } .content ul img { vertical-align: middle; } .content a:visited { color: #4c0033; text-decoration: none; } .content a:visited:hover { color: #4c0033; text-decoration: underline; } a:hover { color: #4c0033; text-decoration: underline; } descr p a { text-decoration: underline; } .descr p a:visited { text-decoration: underline; } .alphaChar{ width:95%; background-color:#F6F6F6; border:1px solid #E6E6E6; -moz-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; font-size:12pt; padding-left:10px; margin-top:10px; margin-bottom:10px; } .flowList{ /*vertical-align:top;*/ /*margin:20px auto;*/ column-count:3; -webkit-column-count:3; -moz-column-count:3; /* column-width:100%; -webkit-column-width:200px; -col-column-width:200px; */ column-gap:41px; -webkit-column-gap:41px; -moz-column-gap:41px; column-rule: 1px dashed #ccc; -webkit-column-rule: 1px dashed #ccc; -moz-column-rule: 1px dashed #ccc; } .flowList dl{ } .flowList dd{ /*display:inline-block;*/ margin-left:10px; min-width:250px; line-height: 1.5; min-width:100%; min-height:15px; } .flowList dd a{ } .mainContent { padding-left:5px; } .content .flowList p{ padding:0px; } .content .alignedsummary { margin: 15px; } .qmltype { text-align: center; font-size: 120%; } .qmlreadonly { padding-left: 5px; float: right; color: #254117; } .qmldefault { padding-left: 5px; float: right; color: red; } .qmldoc { } .generic .alphaChar{ margin-top:5px; } .generic .odd .alphaChar{ background-color: #F6F6F6; } .generic .even .alphaChar{ background-color: #FFFFFF; } .memItemRight{ padding: 0.25em 1.5em 0.25em 0; } .highlightedCode { margin: 1.0em; } .annotated td { padding: 0.25em 0.5em 0.25em 0.5em; } .toc { font-size: 80% } .header .content .toc ul { padding-left: 0px; } .content .toc h3 { border-bottom: 0px; margin-top: 0px; } .content .toc h3 a:hover { color: #00732F; text-decoration: none; } .content .toc .level2 { margin-left: 1.5em; } .content .toc .level3 { margin-left: 3.0em; } .content ul li { background: url(../images/bullet_sq.png) no-repeat 0 0.7em; padding-left: 1em } .content .toc li { background: url(../images/bullet_dn.png) no-repeat 0 5px; padding-left: 1em } .relpage { -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; border: 1px solid #DDDDDD; padding: 25px 25px; clear: both; } .relpage ul { float: none; padding: 1.5em; } h3.fn, span.fn { -moz-border-radius:7px 7px 7px 7px; -webkit-border-radius:7px 7px 7px 7px; border-radius:7px 7px 7px 7px; background-color: #F6F6F6; border-width: 1px; border-style: solid; border-color: #E6E6E6; font-weight: bold; word-spacing:3px; padding:3px 5px; } .functionIndex { font-size:12pt; word-spacing:10px; margin-bottom:10px; background-color: #F6F6F6; border-width: 1px; border-style: solid; border-color: #E6E6E6; -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; width:100%; } .centerAlign { text-align:center; } .rightAlign { text-align:right; } .leftAlign { text-align:left; } .topAlign{ vertical-align:top } .functionIndex a{ display:inline-block; } /* end content elements */ /* footer elements */ .footer { color: #393735; font-size: 0.75em; text-align: center; padding-top: 1.5em; padding-bottom: 1em; background-color: #E6E7E8; margin: 0; } .footer p { margin: 0.25em } .small { font-size: 0.5em; } /* end footer elements */ .item { float: left; position: relative; width: 100%; overflow: hidden; } .item .primary { margin-right: 220px; position: relative; } .item hr { margin-left: -220px; } .item .secondary { float: right; width: 200px; position: relative; } .item .cols { clear: both; display: block; } .item .cols .col { float: left; margin-left: 1.5%; } .item .cols .col.first { margin-left: 0; } .item .cols.two .col { width: 45%; } .item .box { margin: 0 0 10px 0; } .item .box h3 { margin: 0 0 10px 0; } .cols.unclear { clear:none; } } /* end of screen media */ /* start of print media */ @media print { input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft, #feedbackBox, #blurpage, .toc, .breadcrumb, .toolbar, .floatingResult { display: none; background: none; } .content { background: none; display: block; width: 100%; margin: 0; float: none; } } /* end of print media */ /* modify the TOC layouts */ div.toc ul { padding-left: 20px; } div.toc li { padding-left: 4px; } /* Remove the border around images*/ a img { border:none; } /*Add styling to the front pages*/ .threecolumn_area { padding-top: 20px; padding-bottom: 20px; } .threecolumn_piece { display: inline-block; margin-left: 78px; margin-top: 8px; padding: 0; vertical-align: top; width: 25.5%; } div.threecolumn_piece ul { list-style-type: none; padding-left: 0px; margin-top: 2px; } div.threecolumn_piece p { margin-bottom: 7px; color: #5C626E; text-decoration: none; font-weight: bold; } div.threecolumn_piece li { padding-left: 0px; margin-bottom: 5px; } div.threecolumn_piece a { font-weight: normal; } /* Add style to guide page*/ .fourcolumn_area { padding-top: 20px; padding-bottom: 20px; } .fourcolumn_piece { display: inline-block; margin-left: 35px; margin-top: 8px; padding: 0; vertical-align: top; width: 21.3%; } div.fourcolumn_piece ul { list-style-type: none; padding-left: 0px; margin-top: 2px; } div.fourcolumn_piece p { margin-bottom: 7px; color: #40444D; text-decoration: none; font-weight: bold; } div.fourcolumn_piece li { padding-left: 0px; margin-bottom: 5px; } div.fourcolumn_piece a { font-weight: normal; } unity-webapps-qml-0.1+14.04.20140408/docs/getting-started/0000755000015301777760000000000012320723226023404 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/docs/getting-started/UnityWebApps QML.png0000644000015301777760000010175512320722666027136 0ustar pbusernogroup00000000000000PNG  IHDR_wIDATx]u}'D!AB  (+ *(aLm/XRШ槩]2,ۂf):awّqQ2u;L:[7oi !ߜI'y^3I{9>y~9i{V<~{wwӓIJ)P``X@VP`XN`_1]֕%cgy{Uk byz<1me=kw"2xZOV=X< R*jm)zQ>EskctZ^e+F䇪¸99ۛCWՇsTzSOiWURRR9y9֫Kqϋ5)\U#+^)1[ʼ(XY^xb}y]`Pt Ja̫l,\CSp6eZMG]YX7*z_R`2z\Qɽ:~^4GP,ǵOuW ڣ7&{xae>Vee L1z8"ęqt(qb~-(y8FMr8wmKF( |3bay}oioYw4, 0, 0, 0, 0+( 0-OC~96)qsQ?+YOCUDfLwzm?76{&ʎ3DdVe?bCf9zg{]ſ[~?|koͺ O|"2C7|dM-z̙.ď7!}ܛ;ͷ}zB|QDfI<" P`)bn??կMDdR]zM-+SA]tDDҼןq6H1/vNwɟ "O|9 M.O{>+pytvhiAP?&x{vQLwY_VVŎK.LFN=^l (Ӳ ĖfOO7;=7׍ͱݴдqVm=G[,n,sPL7F,Fhp.]@@;en)k˿sZeiA)|YtT2cKʴVUӚ_Jh\[qSsȣm͑ ˴_QV6oH^*oxS`iyx#^-U2/a h˛u}_jH^Vc~~۲q<w=i/"x8 n]@xa)C=m~gJr5.Һ'ʴӈݻFgKqϢV!|d{׻Z,Ce>uK>Z./[#XspdziyC~Zt?_)DnB|Ysl-xEUyܾU._W^]+c,yZ?p/P s<秽O9@ k (3*` U\`)icU*Wڌ|UߛUQBb5*9猪mX~U7B8z$55:۴ {C7G/0˻|}ՐzպUޘ' Rj9|5 ep\jW8`/"R/ytKazX]*zaXnDZJZ[PeSaѻ֫F=L{F))#K)~zܰsؿTXnRT2 p5{yo]vo79◡wGȤ|/ϸGJYQWIkuR VV-Ts_-}Bl{G)}=Z>7dVXC !&V~5[Qۆq< > LzͶp/ϸQֆᴷT. ><ߵ-ϣm>5_9z[5:?]^ʿGz 2 [,{yZޱ2 s4 ^lӥpäfW56dh (3[2t]2XQ_e=RfC=mi=ȟM LĶaj (Ӻomy͡罫ܾ*@]5{Q)JJ{5ezQjݶcqyKtru}Cq{WR_*QJk츭7B`PqQ8R|oUXD`@QRzj G=y(("" 0+ ( 0+ (   (   ((" ( (, 0(7CϞIF?e,"(("" 0 (6("," 0("," 0 ," 0  hvZVS("" 005 ~z2i]`P`XDD`@QXPED( 0," 0(" f}{?׺-Mdr=k6'^SP\/*[ZqA:|?7V( q g)sZDz.Gxєzfsv7{o 0+S L+pCkr{~QUZZmzx})xb5+.Kaw%Kz!K˼/_? U_S1G{UY^U^[[x{R7Wey62u;\\q]Cv\8Rx޿}.i]C;O餍6w8s0RO?F#V7S?WJo}Pw׃:77{|<ƼE{2Q1O_qa#qNoJ(< (cXlZW ףa~,qN-8]XS-qS,VAGY-͡Cߠýcy#yYjюbqkY2֣y O`EUu4OC8$6FQ;+ hVۉQ(1ڌpc=kuZ(QLa]uuq ), 0?q;1(\o0hb{4kE6G?:_U9<E=>CsxRX`YV(#])n >5Jpd{ZHGv~nL=6(w7E3F G׺-̹]kdQziQX?]ӌyá5=칆1ݮ+%:]|GްZPEeXD`@@PE`XD`@V  ( 0,"((" ( (( (("" 0  ," ( (  ,"(("" 0 ( ( ((vED@QPED``XDfU>~cM6o[bg;~ιLzYp>ιLz_}m6obg_^˯9΢7/~l~8ޖo:윋d{_=,l~8B~{?."oܺʛc˛e0~vBkGXDfG~V)qҲ>ng,M]十"3,%WekNS`\o٩q~ )%LIsN:;mubے6omZV9//"|8gQ`W`;W~x9J^c T9w9աKh ,"36-)x+ ( ( ((ӹ;wc/=[Cozpw߼cu>cw>m/oƯxxc|ccN]zWo?7m\y_g+ck6׿ xwZQxq1z>5 PW=7Fs}KCz˳׏i^{mW^8(]t9 (qnpDY㹲\v%GFnμmXb<Ĉ`}{jUb1xL/~ں|/-+Xg2#irſ1_Q~1>8by귽]E|y]8K'W;{nr7_+WU0fuӊ&~t~c9;?˯SD`P'GGE6"X]@h`*Q:eeQ(l ևfQC,.1OQBg^w(ձNcۣbc}ױaofݾt0cډCuώ6^Y&8eg`P'w] }X pŹMQ"j_2 T~/Kb=J0Ǽ;G9eh˘ӭAèpjq(r|?^qasź˻>n~ M9;|*+r?=hF]]fg/6f Qd(RM1FQ"GLjm}p]y r%]DIeZ/uV.=,a8+Qr.FWWoeϣn' ~<&{i4RC 0( 7|LP^)dь*GMDyCcXgq2ډϻ CON]*^mρ*]#өo>Q㘗(qzS(OX,E)Q(]WٍCf'QtFmа+,G<4ϑ?WZE3s4 5:Z|rZ.>#7G̣uva^|Rt,WS>:[w.#}nr'+Oh129"%$O}%c)YxtsTQ&NjypԼR6!?)/U":r\_xGěQVtr9ŧuΫ@e uʢ],s}!%QS̈́Hno,CXbFb񜣕a%:~[xG0Dq(qMٿ]+%w[xۣc^$fBe0eΜX-y<(Y(1ݘ~SFu Hp0c5J^Չ/]=9>#8?IxR/ Z,K$>T8G4\tG!vtDVήigLsErF"qCX8L>9xoSb^[fO`^ !] iR?K <w4♘8_6-nQW<* 0("," 0(","R7ټ0l.;"r̉+x+Szeycf^j T3Na߰/"Gؖ|h T58;ȋȸ }ZUy<;xF_9g򻫟96Le G]w.\ZD+qVvj0ŎkRC+"2Z1 449xu-ŴʗyzW6Jk]);i%\ЪJ~ԪVvmU06+C@3=!/i(.*E9bX~QuV 4UdM):=_Jbbß_n]V -%jU1RVZSڰß3;"mi~~l͡ﹲԳjyV!R"۬)g^V!+P;"rDv? FCq96L+y1vd,}Q{\9tH۳we;ȱWC0SQ}Â79"2Q7f`n??կM;"2a˦`s^re?."ID}sOLx>(6HbKjWD&%я{zZ/D/vJcƎsp<;zNLZ~,mv8Yox?A̓{~;S0kq2 ;|+vEd‹<6okcg􆏬s."V?mg윋Ȥ'l+x/E8eͺ Y7ȌMlkJj ," 0("," 0("+"(("" 0  ," 0("," 0("," 0 ," 0  ,"(("," 0("," 0("9XDD@QPED``Q@`Q@`QPebmo{zއ~em3_Jǿy߿yxד#N|{?cC n֟~|}apXa}~Qw`9OA_ޚuz̙;=oǟ_⺡ӎbwis[~~?F]sFs4猂ӌe~]⍄w_39U{? 0(\~YW jNmAܶ_Xv(mur(_XAm?F}cQptGU~#a7yuߋscӉe7bbܗ_=o9x|]cVPgmL։d8^: :o'E6! y8T}t]>(XQhc6}}Qtq1z"[ׇ.Vu9Q☗xX<;=qs:(FE@ɑԮuuj1tY'GŨt~9^ÜCyyfGs8$8F닁s)u]h+ε"Z.1".sE!n=?Q HWPgm؍e=fr.QՇAG1rNt'?sQBQ?yy9bw}R]s=#]eX:.%9uHzv#yXs<.oL?syѭ, 0 29}ظo< pHևAGYG;'t$7Ce7!oO]ϮyOjʨo{d71vtkuElQPgUXYR e#a]C9::GyJ,N;7Grc6EX()=͏e87,}GJN>ܺNqq~p"i_^~ս;>޷C@fTL-F'>%^֫o1YqT+W\7M\4+vEcύ-zEG> ~Ǘ_}msT^yslsy fy~^h*"u\Zv-l9y.1}\~W6>l-EjU1#~hu(3ժC|/JhGoJ>94ß 0MWh5MI;`AtxSﶚß3{#XJӁ!ej?)gbn?/P`At: :Gz nAV ~ʪ\`}U4yt+ (ytg*3R}|D0軭 `&àتPiN)}+9xYm<3K}:sgrsm]ϩv>`A?y4G~L<<Mۼ~.geYW>f_~zXXy/_xҗ蕽/L\o޻Ńg/K~vglkNyw~j1E۽N>Fɧo?~n+;Ń?W./~ow_L|[ٻix#J_5 KN:o;Χ~jEg+V>)f>[w M0w}f8w}S캷>fAdf[i=jqg3\vtRr;󵃢n!.2˨0촼=!F;|7Ewy)ʶ [=Crj[w~wwY_j[yEvfˋ`Ł۷HY~xt Vv cfE}{.} ^wY_R}el[ɼȜi[_ }myYD6T̀-qEw^Os[}]e1);}5k<6Mw  {y\DdXb9l{W:5B8^S3_nb{l_w\?Dd,W%i~"2]U0maw1Dd\WN8 ws"2]u8FU88o* 9餓bp*v檦\*>k'"G+ 0ؐ_+aNlCJ fj9q&5ȱn8`ZE/QG"rL_~w rp +/z1o^tSx{@9_G*?+#SE?| ^+]?/NC\LX.)>w<]˽F"2ӷw4#Dd"WV.)_F"2ۻrD|S6!"2YdSa lvƼwymDdw0ƹ"2I*;OO 1/YÒP_qg+>on^tw+b^tED&m{7u2w qLrXpt\"2w Llhd-7'p{78׼&"2ӷwtßEd2G~+w_8Aۻ"kyމL0@Lvz眿k!"N?u 08_xٛLv޼,WŗIϛ~i`[b\ꏕLzb[Svo9ۻW^ ;Ur?V"2YvמEdvlbkl쏕Lz蕹CNDlC("36);[mD;"bNDlC("vmD;"bNDlC(" 흈( BQED`XDDQ`XDDPED` B;!;B;!;"މ !XDDPED`@QED`XDD;`Ch{'"w!;w"b{BCh{'"w!;w"`PD`;Q`DDQ`XDDPED`@QEXDމvE흈`PDމvE흈(!k!" 0,"( ,"(""  ("b{,"vmD;"bNDlC("vmD;"bND`,"(""  ("" 0,"( ɪ_zs޻7W{_ok}߹s\ӹm | G7n Cz︞W?ƻ̟_<杷~.Y]vىe'I>ggA۟>;=Xq8ΝFퟺ훾#>߽x̰a_~nT8-9#_uB^:mٺ߻y\_7޽w>^aVN`f}>N.qO{?6xlg n7mk8k޸DI߹,mð=ڿ?4|2osWμ3_[vN?3қvߙ\(3w5ivm+>v4v<v&&tg;]FFyoMxs;wⵌao>dшO;TX>a}KN+3i~0(QͯaQMs߻e׽eXWlS [bGRoN䛇̿ZC`YChvfg|/Fd};\] vaY$DƎp,e:RеpDmc x\;Yz6:wGS<(1}d=v+ {R}XvvϝUWqqƼcc/棫_7҈a#'?Dzr\{$ :mx\;]*3*~wm5~w(^ bFщ߭<]\#Qw$1{ӯr[dnEX^L+9 h82|x\|amzK;?{1/Qbffn_,glbzgFLq7_X]Av,0/7b]m}VcsmOu;Rsv1X !(;0x | pqR|׺P!>vbG}l<6Gd;9PW}aoTj3ɑܑk,䡎rǻޑ bwRs=ړDC.q{|?_Gcb}k;֋diz-c}tW?v1+: geɒ~`9ǺF۰C Gadݍx}!x#+Gǘ: r,m@q\(hd*Ay4J(\1۲zD2'+e(zcz]n߄&Cu1iic۞^ӏ1T̟Ȁ:썔\_7@@>}iňX p$ ^+wsg0XY0aeh pײ0QSG!|vH乒Ϯ~vl+ߛr8ϑ.tYZ⍨|=+24rT5on [ ˕Ght,19"Fe(uuYRh(y<*~͆\?7~$=wB._1NvNqz8?J}PPO@-c-#y8b{cg$Ki>yw<ܑGXc(;߫w4cyz#Ϲ;~y(M2l:4:SBy X#XG11ٮG$ײ}t~; vW~^C}J]FoQ.8/.]?CGSQܮeQ߃vI}uL7 rېz{5oc-Ɍ0XF (bSp A q0-.5@bB!Sbd!;"cSDBDI[[TV&j&!09sɚ>{{ٿgww\I;bKK2݊ɽzXm4 Ur=ww<#IN #j{sQMU/|z21d׾־2SUD-I˃^cTF[:\7nD/ l%m~%:5~OL5WW1^2eo=َ囩b;-1sٖA'QuU+!ݟ<\D:1}ru4@vֶ[o/PT-5^lܖ+c3*Ie_ aaWze%Sۖ3m^vk 5qMMvr qewV% ݱxŶpQ]w_9+o w;{. V];^S[\C 5jiC1xl*m5KU6Kp}e5^bw''=ٯV]U{TX٤3Y c"gZx+V5NQ2v⼾s70nKmٺn8Xs1UV糞Iunumtg0 T%y}An#5WV4V-J<Ѯ^2hݒnbW I禽V VĥUB25ۈQڝa{ksن$Yn&)rǸ|{L#JӛWA۾wF0UzU7k}V#T{g1^w_>hY(b[Au4(pNؙn̬ʖ~Q2O=wuvQjb\;8Y`e[IRۑ,I^/-yƭU[8= IkڞJ|. U\{Z% V IwmSz~*c6tߑכ_c&|o-%3*>58.a\m'nIS]zpf+իűZFb`wlO5B&fW#S{۝A8fܓe QfS)/S~qQ+ciwbbuޚ0+F~*k]bybY~VzWn)>KOc]}l]}c8/Mb> p%.nɦiLkFqUN7-l{v,`$L٧v|Z;ߖK&9$z=}yJdV]mC~n$5x0yf׌$/lچ$j$ו fj pt{4c«**sUnUȑڡn5x6tVV_oePU|TȲ*1JB$q %]f7Sq;}Z}{TLN5ֹk&iCmLq*K}=tm|qILL]o96}7g/ͱN nC|>KkcZgblki7Fնu§[9v4O>mZug9\Է|ϧg{۞j|cTTX8|}vqI=``mTq5μ7n&Γ^ͪI&Zl5l3w *SZS"qVY&lbIB(-{jrv]&`Zq5X9)W =q 1ǂIe ``US7ޘ```""`""&"P#" !$" xGD@BHDB;$1 !1DD 00DD 0 0LDLD11D$`"wD$$D$!HHHB(xP#" !$"&"b&"b```""`"2D$`"wD$$D$!HHHB(xP#" !$"&"b&"b```"``HBx`HB(xP#" !$" xGD@BHDB``""`""&"b&"bHc&" !LD&" xGD@BHDB;V.JwD$nHpzXђ_ GB۟u_G "Zr]#MX>$ 'VD:fݻ~9D~i;w|H:<-w>(ĻK^炈\zx] ˇ$Óђk & ᖣޗuw;DZvMŻMX>lJp^aݛ{`ђ遯Q(ŻY| ԧݟJ5`yx`&h"ZbeIA ˏs7o2h"Z %xp&*av) -ھ 2eDDW>V!tc]&=熈KXˠBJ[Kٖ+R熈]?xʟ`&!E]_-+٦ˮsDD֝;]nV'-y__O<̈u?[`*LNYFn< ۯ~¹"#VUL]^/^Z + :hDXc[n<8grHI2b.N gCE"*,p>Ȭ-D0[+=+iI)Yh!{U {C>\n_=/;"QC;۾m4V&7~WO]YI~ oVD0 O|ז=ќď5kI`sf1:"ӤW'||GWHd5/fS\z~k֮I`pCs MED3r 5 +5 jzC4e̓21O: 'x͚5zGSJLo`edKgL}q#8N]'wJ`u}o%y[/Ð]_yw`;խ+<ŸWf>H`"_両/c ֭ѿ[I}rW%%? ׮]S%gKWQ5k&ae}p;Dǖ؟yP6oVܷB\ Qbz|iÒ\a݁7] c]uIK~V*W*woX%pL/M9}R(*_k/7vHNLj'ig2|_:!Z={s_n7~9m#foƖwc3=~A|ޓJUzwsfLz)^ q,# &<Vq[nk{yil<(̌8$Uy-̍ؿw~X#Z=:n?YaÓ_\0eS\li)&辑֮]͛7M~?:p˖-Ol=1WtI:sq':?#=ޜ'5uw7V)#s<1<Nг#22IXnb֬YwНzꩽz{;<{u ?/{޽{>Dg}_daÆŎ.C};wr-nr[+K)GGRȾ&5]taf!r-{> ~퐞}oo *DZ=Q{ܣ~=sykϟ8twqE֮]z[F~~ybS=pKÙeᴑL Azj_6_׼q-swŠ~k_cJiV}>d/Gy0c} 7ɟK F>8bȘFIO?DLMR2|O?@&1No͛< 'puIw>11QtUMU&nk_i}n|}u]86g96Q> C;vkW0 9.:/qrGKlݺ/5ۭtu2g}jrVô}Hcô;VLKN8\?Rty獯={Kpڥ8cG5#"*g*.߸SO tTƴDh޽|W O)1B=oEtڴiӁ:#z F=7iJufR}"0܂0D$1wPuU}2h]|9J}gRJ5)g1"D$$bD$1wHHĈHb*8T%g`D$.8yhT%g1""K$$bDDSqHHĈ$.8-G]s9gOOUW]5Be}s=r]ww%L̾}ƟӮ]7t_3lmWYE]D @"9e]6~p>3|f!pݺu3ovn޼y|pD38?~O?0te;o~Xw7;AMײk:Xv?ӫܚn L3ƾ]GLyws|>Kk)ϬR{bx:2:cuDzꩇ}Oý%1] 8`ł4^vn52|&kۀ׺0@Y}ݷ`vs=S \T U4t35^&6/|[n6q̺{,sκ:˩ij|&U=c^(۔uv߾l״s($bgX Z$G'!K8hwv0#%يыi6ބ5Idb2wM:c1IxfcFg;99^|?z֗$qKZ5f1.mmvh1Yo#j_9,.3mICS[+'x&SWb*}+c1YV5eY54ZUa&%$+ʲUuH[8Ў[װTӮmj;aq1o$Į;2yn%q9ϥJI0gXwd0;-[_$XZVzfۇ$u~kj[$`ُVNNb3v˄S*b&=cPb%?g[ݚә pwFIczsݩuTrMdx8kpUoz#G[URI m} l5;\6qy1n/W^4 pmsrgAL:q rť/ǧLlacZTwFscXv!i8>D|Tomڞ#kIzVHV%ls1YN7JoôqrJ*aIzd[8$2e>ටxVR7lĹ6(=Qh7dctx׊et2ie|lʌfke8ֽ'kXl81p3ۚ,7soU83b^,p=22[el-}ϚZf r\msL& gUhe 5I"ҲĤ-aK^$'&h۞1ߪozu\|xֱkbkID;8v*&I2,M<ޫmNbU=/fb,+[<8S؍]1aći毪Jf3ךl?2]&w52;ˈZ^X-Q '*m6FYHĖ۳*IGI(1eUn8m"VIe]qm_iYZWM _^2I|/=qiHw,QXb pض`2[|jEU;<[J}R.s6\ vTր;aӮ2<ډkx6u{s󜪱H9<UޖW"T8ereVSW7{`g$)ɶZjg[joZ=$\&~7,d-q.j{jo ro~͹d*2䴸Xr.8C6 ĥwgNmk*iI MDˊcVW5cϏ|[re9iL&g$!IbnLOj{QJc⢚]zm6UZR8&ikgF^NOrN&{akv4:*yK4Υ|wWqm'N6 .ZC;\o3&ڻKI\ p50ָᾊ#1I!(Ȋ;UIΜ\X]spQCIӺ-ݹ)uԘsy>3x&xIR% W L6"H p%*)&r5`ثiUHt p)%r9IǢPNbmJrS Y N<ލ*%:ZG$~ffr\~zX]i5tJ 瞫W.%6WWh' ~zRƻ׶JǦ d g.1ߚ,;*/|}}sv{ jgd>dzz &3&gڤ.?]gswlsnW\G$ɹL%1]m8z7EQ/UQRzR>1jk+f;b,kAh)zĤꭜn+hf{f8sUgA-L̩Yk=;+Xf=5b漴q[5us;Aoپ:\3IU~}% }㯓ͥ!$5ƴq'1}kl̘1TYV^IJYpLRLacb, w'jxI!چ;c޲a Yoʬk{M1*tnlc!ۜmo^%-c+Y_{,sr,8.#ݮQ7hr^7VU1Qy_$J_Z:U/Gʴ۱$1wi9ۛ>3mJ)t w}UzGjo3}e$1wg1ǻkl>Wzs.t2F8=}T%XHĈ$.eto;4eW<3T%g1""K$$bD$1e]"q #"KD @"FDSqD$.8#$bD tWWbOw`yH\s5D袋*11ws9{uAzg$*tI:O>$L|Gs=nmx׎Ǝ;btgppsC$TD؊a$t;!9 i(yL˰IDATnݺWV'|3.lܠy7212 =\wuئ!9vx4lܸqk.䒱i)ٻw︼4,ςx`lc[O=Hq\'idusW;w2zlgڵk>5KnTH) =[==0&+h%51 oc 镑1|MIW1618,f'JO^ PLޱybX3G^x㙆:įsִFK[29*8ke?&aG˕gR`*Q3Cko~z`ͦLNڵkב,'Rf}pp&'F䆉))q"9{s֭oD~ĐAzpOd;mc)}K#C<.w&˓uskch/4Ƙ bH݋S@DǴ2isbvL Pob':5<1W3wc]=OtLktss.ݓ}`B)1IRsG$"M1@EG41qӴ7ϲ_s tٮSJIENDB`unity-webapps-qml-0.1+14.04.20140408/docs/getting-started/getting-started.html0000644000015301777760000000260412320722666027410 0ustar pbusernogroup00000000000000 Unity WebApps QML Component: Getting Started (Work in progress)
Introduction

This is a Quick Start guide for the Unity WebApps QML Component.

High Level diagram

This is a high level reference diagram of the component and its stack.


unity-webapps-qml-0.1+14.04.20140408/docs/getting-started/js/0000755000015301777760000000000012320723226024020 5ustar pbusernogroup00000000000000unity-webapps-qml-0.1+14.04.20140408/docs/getting-started/js/sh_webidl.js0000644000015301777760000001337112320722666026332 0ustar pbusernogroup00000000000000if (! this.sh_languages) { this.sh_languages = {}; } sh_languages['webidl'] = [ [ [ /\/\/\//g, 'sh_comment', 1 ], [ /\/\//g, 'sh_comment', 7 ], [ /\/\*\*/g, 'sh_comment', 8 ], [ /\/\*/g, 'sh_comment', 9 ], [ /\b(?:abstract|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|final|finally|for|function|goto|if|implements|in|instanceof|interface|native|new|null|private|protected|prototype|public|return|static|super|switch|synchronized|throw|throws|this|transient|true|try|typeof|var|volatile|while|with|Unity|Unity.+Interface|optional|dictionary|readonly|attribute|enumeration|UnityTrackMetadata|readwrite)\b/g, 'sh_keyword', -1 ], [ /method|dictionary|interface|String|Callback|UnityInitParameters|UnityIndicatorProperties/g, 'sh_type', -1 ], [ /(\+\+|--|\)|\])(\s*)(\/=?(?![*\/]))/g, ['sh_symbol', 'sh_normal', 'sh_symbol'], -1 ], [ /(0x[A-Fa-f0-9]+|(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?)(\s*)(\/(?![*\/]))/g, ['sh_number', 'sh_normal', 'sh_symbol'], -1 ], [ /([A-Za-z$_][A-Za-z0-9$_]*\s*)(\/=?(?![*\/]))/g, ['sh_normal', 'sh_symbol'], -1 ], [ /\/(?:\\.|[^*\\\/])(?:\\.|[^\\\/])*\/[gim]*/g, 'sh_regexp', -1 ], [ /\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g, 'sh_number', -1 ], [ /"/g, 'sh_string', 10 ], [ /'/g, 'sh_string', 11 ], [ /~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|\/|\?|&|<|>|\|/g, 'sh_symbol', -1 ], [ /\{|\}/g, 'sh_cbracket', -1 ], [ /\b(?:Math|Infinity|NaN|undefined|arguments|Seed|signal|argv|argc|Gtk|GObject|GLib|WebKit)\b/g, 'sh_predef_var', -1 ], [ /\b(?:printf|sprintf|connect|Array|Boolean|Date|Error|EvalError|Function|Number|Object|RangeError|ReferenceError|RegExp|String|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|Unity.+Interface)\b/g, 'sh_predef_func', -1 ], [ /(?:[A-Za-z]|_)[A-Za-z0-9_]*(?=[ \t]*\()/g, 'sh_function', -1 ] ], [ [ /$/g, null, -2 ], [ /(?:?)|(?:?)/g, 'sh_url', -1 ], [ /<\?xml/g, 'sh_preproc', 2, 1 ], [ //g, 'sh_keyword', -1 ], [ /<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g, 'sh_keyword', 6, 1 ], [ /&(?:[A-Za-z0-9]+);/g, 'sh_preproc', -1 ], [ /<(?:\/)?[A-Za-z][A-Za-z0-9]*(?:\/)?>/g, 'sh_keyword', -1 ], [ /<(?:\/)?[A-Za-z][A-Za-z0-9]*/g, 'sh_keyword', 6, 1 ], [ /@[A-Za-z]+/g, 'sh_type', -1 ], [ /(?:TODO|FIXME|BUG)(?:[:]?)/g, 'sh_todo', -1 ] ], [ [ /\?>/g, 'sh_preproc', -2 ], [ /([^=" \t>]+)([ \t]*)(=?)/g, ['sh_type', 'sh_normal', 'sh_symbol'], -1 ], [ /"/g, 'sh_string', 3 ] ], [ [ /\\(?:\\|")/g, null, -1 ], [ /"/g, 'sh_string', -2 ] ], [ [ />/g, 'sh_preproc', -2 ], [ /([^=" \t>]+)([ \t]*)(=?)/g, ['sh_type', 'sh_normal', 'sh_symbol'], -1 ], [ /"/g, 'sh_string', 3 ] ], [ [ /-->/g, 'sh_comment', -2 ], [ //g, 'sh_comment', -2 ], [ /