add a dummy url interceptor
will be used for device specific stuff
This commit is contained in:
parent
8f20c41931
commit
930c8647e6
@ -15,6 +15,7 @@ include_directories(${KDE4_INCLUDE_DIR}/KDE ${PHONON_INCLUDES} ${CMAKE_CURRENT_S
|
|||||||
set(declarative_appletscript_SRCS
|
set(declarative_appletscript_SRCS
|
||||||
declarative/packageaccessmanager.cpp
|
declarative/packageaccessmanager.cpp
|
||||||
declarative/packageaccessmanagerfactory.cpp
|
declarative/packageaccessmanagerfactory.cpp
|
||||||
|
declarative/packageurlinterceptor.cpp
|
||||||
plasmoid/appletinterface.cpp
|
plasmoid/appletinterface.cpp
|
||||||
plasmoid/containmentinterface.cpp
|
plasmoid/containmentinterface.cpp
|
||||||
plasmoid/declarativeappletscript.cpp
|
plasmoid/declarativeappletscript.cpp
|
||||||
|
42
src/scriptengines/qml/declarative/packageurlinterceptor.cpp
Normal file
42
src/scriptengines/qml/declarative/packageurlinterceptor.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Marco Martin <notmart@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "packageurlinterceptor.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
PackageUrlInterceptor::PackageUrlInterceptor(const Plasma::Package &p)
|
||||||
|
: QQmlAbstractUrlInterceptor(),
|
||||||
|
m_package(p)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageUrlInterceptor::~PackageUrlInterceptor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type)
|
||||||
|
{
|
||||||
|
//qDebug() << "Intercepted URL:" << path;
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
40
src/scriptengines/qml/declarative/packageurlinterceptor.h
Normal file
40
src/scriptengines/qml/declarative/packageurlinterceptor.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Marco Martin <notmart@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PACKAGEURLINTERCEPTOR_H
|
||||||
|
#define PACKAGEURLINTERCEPTOR_H
|
||||||
|
|
||||||
|
#include "qqmlabstracturlinterceptor_p.h"
|
||||||
|
|
||||||
|
#include <Plasma/Package>
|
||||||
|
|
||||||
|
class PackageUrlInterceptor: public QQmlAbstractUrlInterceptor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PackageUrlInterceptor(const Plasma::Package &p);
|
||||||
|
virtual ~PackageUrlInterceptor();
|
||||||
|
|
||||||
|
virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Plasma::Package m_package;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,66 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Research In Motion.
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the QtQml module of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3.0 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU General Public License version 3.0 requirements will be
|
||||||
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
//Private API for 5.1 (at least)
|
||||||
|
#ifndef QQMLABSTRACTURLINTERCEPTOR_H
|
||||||
|
#define QQMLABSTRACTURLINTERCEPTOR_H
|
||||||
|
|
||||||
|
#include <QtCore/qurl.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QQmlAbstractUrlInterceptor
|
||||||
|
{
|
||||||
|
Q_FLAGS(InterceptionPoint)
|
||||||
|
public:
|
||||||
|
enum DataType { //Matches QQmlDataBlob::Type
|
||||||
|
QmlFile = 0,
|
||||||
|
JavaScriptFile = 1,
|
||||||
|
QmldirFile = 2,
|
||||||
|
UrlString = 0x1000
|
||||||
|
};
|
||||||
|
|
||||||
|
QQmlAbstractUrlInterceptor() {}
|
||||||
|
virtual ~QQmlAbstractUrlInterceptor() {}
|
||||||
|
virtual QUrl intercept(const QUrl &path, DataType type) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
#endif
|
@ -49,6 +49,7 @@
|
|||||||
#include <kdeclarative/configpropertymap.h>
|
#include <kdeclarative/configpropertymap.h>
|
||||||
#include <kdeclarative/qmlobject.h>
|
#include <kdeclarative/qmlobject.h>
|
||||||
#include "declarative/packageaccessmanagerfactory.h"
|
#include "declarative/packageaccessmanagerfactory.h"
|
||||||
|
#include "declarative/packageurlinterceptor.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(AppletInterface*)
|
Q_DECLARE_METATYPE(AppletInterface*)
|
||||||
|
|
||||||
@ -112,6 +113,10 @@ void AppletInterface::init()
|
|||||||
delete factory;
|
delete factory;
|
||||||
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
|
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
|
||||||
|
|
||||||
|
//Hook generic url resolution to the applet package as well
|
||||||
|
//TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick?
|
||||||
|
engine->setUrlInterceptor(new PackageUrlInterceptor(m_appletScriptEngine->package()));
|
||||||
|
|
||||||
m_qmlObject->setSource(QUrl::fromLocalFile(m_appletScriptEngine->mainScript()));
|
m_qmlObject->setSource(QUrl::fromLocalFile(m_appletScriptEngine->mainScript()));
|
||||||
|
|
||||||
if (!m_qmlObject->engine() || !m_qmlObject->engine()->rootContext() || !m_qmlObject->engine()->rootContext()->isValid() || m_qmlObject->mainComponent()->isError()) {
|
if (!m_qmlObject->engine() || !m_qmlObject->engine()->rootContext() || !m_qmlObject->engine()->rootContext()->isValid() || m_qmlObject->mainComponent()->isError()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user