manage plasmapackage:/ with the interceptor

not with the networkaccessmanager
This commit is contained in:
Marco Martin 2013-10-24 12:47:17 +02:00
parent b071260d15
commit 6ff8554ae7
2 changed files with 7 additions and 5 deletions

View File

@ -41,6 +41,13 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
{ {
//qDebug() << "Intercepted URL:" << path; //qDebug() << "Intercepted URL:" << path;
if (path.scheme() == QStringLiteral("plasmapackage")) {
QUrl pkgUrl;
pkgUrl.setScheme(QStringLiteral("file"));
pkgUrl.setPath(m_package.filePath(0, path.path()));
return pkgUrl;
}
//TODO: security: permission for remote urls //TODO: security: permission for remote urls
if (!path.isLocalFile() ) { if (!path.isLocalFile() ) {
return path; return path;

View File

@ -107,11 +107,6 @@ void AppletInterface::init()
//use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled //use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled
QQmlEngine *engine = m_qmlObject->engine(); QQmlEngine *engine = m_qmlObject->engine();
QQmlNetworkAccessManagerFactory *factory = engine->networkAccessManagerFactory();
engine->setNetworkAccessManagerFactory(0);
delete factory;
//engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
engine->setNetworkAccessManagerFactory(PackageUrlInterceptor::createPackageAccessManagerFactory(m_appletScriptEngine->package()));
//Hook generic url resolution to the applet package as well //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? //TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick?