summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-05 12:23:13 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-05 12:23:13 +0200
commit326bd84c8429f11e12850ee3aa4693ab1848233d (patch)
tree832072a0fb1d85618402b83cffb9d8ab1e5d827d /src/gui/util
parentb220fcb1a88cba554335e15588590a1cdbb20db9 (diff)
move some more files into proper places
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qdesktopservices.cpp309
-rw-r--r--src/gui/util/qdesktopservices.h91
-rw-r--r--src/gui/util/qdesktopservices_mac.cpp188
-rw-r--r--src/gui/util/qdesktopservices_qpa.cpp93
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp461
-rw-r--r--src/gui/util/qdesktopservices_win.cpp267
-rw-r--r--src/gui/util/qdesktopservices_x11.cpp242
-rw-r--r--src/gui/util/util.pri2
8 files changed, 0 insertions, 1653 deletions
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
deleted file mode 100644
index 2c2c3308ca..0000000000
--- a/src/gui/util/qdesktopservices.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdesktopservices.h"
-
-#ifndef QT_NO_DESKTOPSERVICES
-
-#include <qdebug.h>
-
-#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
-#include "qdesktopservices_qpa.cpp"
-#elif defined(Q_WS_X11)
-#include "qdesktopservices_x11.cpp"
-#elif defined(Q_WS_WIN)
-#include "qdesktopservices_win.cpp"
-#elif defined(Q_WS_MAC)
-#include "qdesktopservices_mac.cpp"
-#elif defined(Q_OS_SYMBIAN)
-#include "qdesktopservices_s60.cpp"
-#endif
-
-#include <qhash.h>
-#include <qobject.h>
-#include <qcoreapplication.h>
-#include <qurl.h>
-#include <qmutex.h>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenUrlHandlerRegistry : public QObject
-{
- Q_OBJECT
-public:
- inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {}
-
- QMutex mutex;
-
- struct Handler
- {
- QObject *receiver;
- QByteArray name;
- };
- typedef QHash<QString, Handler> HandlerHash;
- HandlerHash handlers;
-
-public Q_SLOTS:
- void handlerDestroyed(QObject *handler);
-
-};
-
-Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
-
-void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
-{
- HandlerHash::Iterator it = handlers.begin();
- while (it != handlers.end()) {
- if (it->receiver == handler) {
- it = handlers.erase(it);
- } else {
- ++it;
- }
- }
-}
-
-/*!
- \class QDesktopServices
- \brief The QDesktopServices class provides methods for accessing common desktop services.
- \since 4.2
- \ingroup desktop
-
- Many desktop environments provide services that can be used by applications to
- perform common tasks, such as opening a web page, in a way that is both consistent
- and takes into account the user's application preferences.
-
- This class contains functions that provide simple interfaces to these services
- that indicate whether they succeeded or failed.
-
- The openUrl() function is used to open files located at arbitrary URLs in external
- applications. For URLs that correspond to resources on the local filing system
- (where the URL scheme is "file"), a suitable application will be used to open the
- file; otherwise, a web browser will be used to fetch and display the file.
-
- The user's desktop settings control whether certain executable file types are
- opened for browsing, or if they are executed instead. Some desktop environments
- are configured to prevent users from executing files obtained from non-local URLs,
- or to ask the user's permission before doing so.
-
- \section1 URL Handlers
-
- The behavior of the openUrl() function can be customized for individual URL
- schemes to allow applications to override the default handling behavior for
- certain types of URLs.
-
- The dispatch mechanism allows only one custom handler to be used for each URL
- scheme; this is set using the setUrlHandler() function. Each handler is
- implemented as a slot which accepts only a single QUrl argument.
-
- The existing handlers for each scheme can be removed with the
- unsetUrlHandler() function. This returns the handling behavior for the given
- scheme to the default behavior.
-
- This system makes it easy to implement a help system, for example. Help could be
- provided in labels and text browsers using \gui{help://myapplication/mytopic}
- URLs, and by registering a handler it becomes possible to display the help text
- inside the application:
-
- \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 0
-
- If inside the handler you decide that you can't open the requested
- URL, you can just call QDesktopServices::openUrl() again with the
- same argument, and it will try to open the URL using the
- appropriate mechanism for the user's desktop environment.
-
- \sa QSystemTrayIcon, QProcess
-*/
-
-/*!
- Opens the given \a url in the appropriate Web browser for the user's desktop
- environment, and returns true if successful; otherwise returns false.
-
- If the URL is a reference to a local file (i.e., the URL scheme is "file") then
- it will be opened with a suitable application instead of a Web browser.
-
- The following example opens a file on the Windows file system residing on a path
- that contains spaces:
-
- \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2
-
- If a \c mailto URL is specified, the user's e-mail client will be used to open a
- composer window containing the options specified in the URL, similar to the way
- \c mailto links are handled by a Web browser.
-
- For example, the following URL contains a recipient (\c{user@foo.com}), a
- subject (\c{Test}), and a message body (\c{Just a test}):
-
- \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 1
-
- \warning Although many e-mail clients can send attachments and are
- Unicode-aware, the user may have configured their client without these features.
- Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs.
-
- \sa setUrlHandler()
-*/
-bool QDesktopServices::openUrl(const QUrl &url)
-{
- QOpenUrlHandlerRegistry *registry = handlerRegistry();
- QMutexLocker locker(&registry->mutex);
- static bool insideOpenUrlHandler = false;
-
- if (!insideOpenUrlHandler) {
- QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme());
- if (handler != registry->handlers.constEnd()) {
- insideOpenUrlHandler = true;
- bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, Q_ARG(QUrl, url));
- insideOpenUrlHandler = false;
- return result; // ### support bool slot return type
- }
- }
-
- bool result;
- if (url.scheme() == QLatin1String("file"))
- result = openDocument(url);
- else
- result = launchWebBrowser(url);
-
- return result;
-}
-
-/*!
- Sets the handler for the given \a scheme to be the handler \a method provided by
- the \a receiver object.
-
- This function provides a way to customize the behavior of openUrl(). If openUrl()
- is called with a URL with the specified \a scheme then the given \a method on the
- \a receiver object is called instead of QDesktopServices launching an external
- application.
-
- The provided method must be implemented as a slot that only accepts a single QUrl
- argument.
-
- If setUrlHandler() is used to set a new handler for a scheme which already
- has a handler, the existing handler is simply replaced with the new one.
- Since QDesktopServices does not take ownership of handlers, no objects are
- deleted when a handler is replaced.
-
- Note that the handler will always be called from within the same thread that
- calls QDesktopServices::openUrl().
-
- \sa openUrl(), unsetUrlHandler()
-*/
-void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method)
-{
- QOpenUrlHandlerRegistry *registry = handlerRegistry();
- QMutexLocker locker(&registry->mutex);
- if (!receiver) {
- registry->handlers.remove(scheme);
- return;
- }
- QOpenUrlHandlerRegistry::Handler h;
- h.receiver = receiver;
- h.name = method;
- registry->handlers.insert(scheme, h);
- QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
- registry, SLOT(handlerDestroyed(QObject*)));
-}
-
-/*!
- Removes a previously set URL handler for the specified \a scheme.
-
- \sa setUrlHandler()
-*/
-void QDesktopServices::unsetUrlHandler(const QString &scheme)
-{
- setUrlHandler(scheme, 0, 0);
-}
-
-/*!
- \enum QDesktopServices::StandardLocation
- \since 4.4
-
- This enum describes the different locations that can be queried by
- QDesktopServices::storageLocation and QDesktopServices::displayName.
-
- \value DesktopLocation Returns the user's desktop directory.
- \value DocumentsLocation Returns the user's document.
- \value FontsLocation Returns the user's fonts.
- \value ApplicationsLocation Returns the user's applications.
- \value MusicLocation Returns the users music.
- \value MoviesLocation Returns the user's movies.
- \value PicturesLocation Returns the user's pictures.
- \value TempLocation Returns the system's temporary directory.
- \value HomeLocation Returns the user's home directory.
- \value DataLocation Returns a directory location where persistent
- application data can be stored. QCoreApplication::applicationName
- and QCoreApplication::organizationName should work on all
- platforms.
- \value CacheLocation Returns a directory location where user-specific
- non-essential (cached) data should be written.
-
- \sa storageLocation() displayName()
-*/
-
-/*!
- \fn QString QDesktopServices::storageLocation(StandardLocation type)
- \since 4.4
-
- Returns the default system directory where files of \a type belong, or an empty string
- if the location cannot be determined.
-
- \note The storage location returned can be a directory that does not exist; i.e., it
- may need to be created by the system or the user.
-
- \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
- with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
- have desktop concept, DesktopLocation returns same path as DocumentsLocation.
- Rest of the standard locations point to folder on same drive with executable, except
- that if executable is in ROM the folder from C drive is returned.
-*/
-
-/*!
- \fn QString QDesktopServices::displayName(StandardLocation type)
-
- Returns a localized display name for the given location \a type or
- an empty QString if no relevant location can be found.
-*/
-
-QT_END_NAMESPACE
-
-#include "qdesktopservices.moc"
-
-#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/gui/util/qdesktopservices.h b/src/gui/util/qdesktopservices.h
deleted file mode 100644
index 9d5657ecca..0000000000
--- a/src/gui/util/qdesktopservices.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDESKTOPSERVICES_H
-#define QDESKTOPSERVICES_H
-
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_DESKTOPSERVICES
-
-class QStringList;
-class QUrl;
-class QObject;
-
-class Q_GUI_EXPORT QDesktopServices
-{
-public:
- static bool openUrl(const QUrl &url);
- static void setUrlHandler(const QString &scheme, QObject *receiver, const char *method);
- static void unsetUrlHandler(const QString &scheme);
-
- enum StandardLocation {
- DesktopLocation,
- DocumentsLocation,
- FontsLocation,
- ApplicationsLocation,
- MusicLocation,
- MoviesLocation,
- PicturesLocation,
- TempLocation,
- HomeLocation,
- DataLocation,
- CacheLocation
- };
-
- static QString storageLocation(StandardLocation type);
- static QString displayName(StandardLocation type);
-};
-
-#endif // QT_NO_DESKTOPSERVICES
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDESKTOPSERVICES_H
-
diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/util/qdesktopservices_mac.cpp
deleted file mode 100644
index e9868471cb..0000000000
--- a/src/gui/util/qdesktopservices_mac.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_DESKTOPSERVICES
-
-#include <qprocess.h>
-#include <qstringlist.h>
-#include <qdir.h>
-#include <qurl.h>
-#include <qstringlist.h>
-#include <private/qcore_mac_p.h>
-#include <qcoreapplication.h>
-
-#include <ApplicationServices/ApplicationServices.h>
-
-QT_BEGIN_NAMESPACE
-
-/*
- Translates a QDesktopServices::StandardLocation into the mac equivalent.
-*/
-OSType translateLocation(QDesktopServices::StandardLocation type)
-{
- switch (type) {
- case QDesktopServices::DesktopLocation:
- return kDesktopFolderType; break;
-
- case QDesktopServices::DocumentsLocation:
- return kDocumentsFolderType; break;
-
- case QDesktopServices::FontsLocation:
- // There are at least two different font directories on the mac: /Library/Fonts and ~/Library/Fonts.
- // To select a specific one we have to specify a different first parameter when calling FSFindFolder.
- return kFontsFolderType; break;
-
- case QDesktopServices::ApplicationsLocation:
- return kApplicationsFolderType; break;
-
- case QDesktopServices::MusicLocation:
- return kMusicDocumentsFolderType; break;
-
- case QDesktopServices::MoviesLocation:
- return kMovieDocumentsFolderType; break;
-
- case QDesktopServices::PicturesLocation:
- return kPictureDocumentsFolderType; break;
-
- case QDesktopServices::TempLocation:
- return kTemporaryFolderType; break;
-
- case QDesktopServices::DataLocation:
- return kApplicationSupportFolderType; break;
-
- case QDesktopServices::CacheLocation:
- return kCachedDataFolderType; break;
-
- default:
- return kDesktopFolderType; break;
- }
-}
-
-static bool lsOpen(const QUrl &url)
-{
- if (!url.isValid() || url.scheme().isEmpty())
- return false;
-
- QCFType<CFURLRef> cfUrl = CFURLCreateWithString(0, QCFString(QString::fromLatin1(url.toEncoded())), 0);
- if (cfUrl == 0)
- return false;
-
- const OSStatus err = LSOpenCFURLRef(cfUrl, 0);
- return (err == noErr);
-}
-
-static bool launchWebBrowser(const QUrl &url)
-{
- return lsOpen(url);
-}
-
-static bool openDocument(const QUrl &file)
-{
- if (!file.isValid())
- return false;
-
- // LSOpen does not work in this case, use QProcess open instead.
- return QProcess::startDetached(QLatin1String("open"), QStringList() << file.toLocalFile());
-}
-
-/*
- Constructs a full unicode path from a FSRef.
-*/
-static QString getFullPath(const FSRef &ref)
-{
- QByteArray ba(2048, 0);
- if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
- return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
- return QString();
-}
-
-QString QDesktopServices::storageLocation(StandardLocation type)
-{
- if (type == HomeLocation)
- return QDir::homePath();
-
- if (type == TempLocation)
- return QDir::tempPath();
-
- short domain = kOnAppropriateDisk;
-
- if (type == DataLocation || type == CacheLocation)
- domain = kUserDomain;
-
- // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
- FSRef ref;
- OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
- if (err)
- return QString();
-
- QString path = getFullPath(ref);
-
- if (type == DataLocation || type == CacheLocation) {
- if (QCoreApplication::organizationName().isEmpty() == false)
- path += QLatin1Char('/') + QCoreApplication::organizationName();
- if (QCoreApplication::applicationName().isEmpty() == false)
- path += QLatin1Char('/') + QCoreApplication::applicationName();
- }
-
- return path;
-}
-
-QString QDesktopServices::displayName(StandardLocation type)
-{
- if (QDesktopServices::HomeLocation == type)
- return QObject::tr("Home");
-
- FSRef ref;
- OSErr err = FSFindFolder(kOnAppropriateDisk, translateLocation(type), false, &ref);
- if (err)
- return QString();
-
- QCFString displayName;
- err = LSCopyDisplayNameForRef(&ref, &displayName);
- if (err)
- return QString();
-
- return static_cast<QString>(displayName);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/gui/util/qdesktopservices_qpa.cpp b/src/gui/util/qdesktopservices_qpa.cpp
deleted file mode 100644
index 324fa51a62..0000000000
--- a/src/gui/util/qdesktopservices_qpa.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qcoreapplication.h>
-#include <qdir.h>
-
-QT_BEGIN_NAMESPACE
-
-static bool launchWebBrowser(const QUrl &url)
-{
- Q_UNUSED(url);
- qWarning("QDesktopServices::launchWebBrowser not implemented");
- return false;
-}
-
-static bool openDocument(const QUrl &file)
-{
- Q_UNUSED(file);
- qWarning("QDesktopServices::openDocument not implemented");
- return false;
-}
-
-
-QString QDesktopServices::storageLocation(StandardLocation type)
-{
- if (type == DataLocation) {
- QString qwsDataHome = QLatin1String(qgetenv("QWS_DATA_HOME"));
- if (qwsDataHome.isEmpty())
- qwsDataHome = QDir::homePath() + QLatin1String("/.qws/share");
- qwsDataHome += QLatin1String("/data/")
- + QCoreApplication::organizationName() + QLatin1Char('/')
- + QCoreApplication::applicationName();
- return qwsDataHome;
- }
- if (type == QDesktopServices::CacheLocation) {
- QString qwsCacheHome = QLatin1String(qgetenv("QWS_CACHE_HOME"));
- if (qwsCacheHome.isEmpty())
- qwsCacheHome = QDir::homePath() + QLatin1String("/.qws/cache/");
- qwsCacheHome += QCoreApplication::organizationName() + QLatin1Char('/')
- + QCoreApplication::applicationName();
- return qwsCacheHome;
- }
-
- qWarning("QDesktopServices::storageLocation %d not implemented", type);
- return QString();
-}
-
-QString QDesktopServices::displayName(StandardLocation type)
-{
- Q_UNUSED(type);
- qWarning("QDesktopServices::displayName not implemented");
- return QString();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
deleted file mode 100644
index 8caeb74fec..0000000000
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <qcoreapplication.h>
-#include <qdir.h>
-#include <qurl.h>
-#include <private/qcore_symbian_p.h>
-
-#include <f32file.h> // TDriveUnit etc
-#include <pathinfo.h> // PathInfo
-
-#ifndef USE_SCHEMEHANDLER
-#ifdef Q_WS_S60
-// This flag changes the implementation to use S60 CDcoumentHandler
-// instead of apparc when opening the files
-#define USE_DOCUMENTHANDLER
-#endif
-
-#include <txtrich.h> // CRichText
-#include <eikenv.h> // CEikonEnv
-#include <apgcli.h> // RApaLsSession
-#include <apgtask.h> // TApaTaskList, TApaTask
-#include <rsendas.h> // RSendAs
-#include <rsendasmessage.h> // RSendAsMessage
-
-#ifdef USE_DOCUMENTHANDLER
-#include <DocumentHandler.h> // CDocumentHandler
-#include <AknServerApp.h>
-#endif
-#else // USE_SCHEMEHANDLER
-#include <schemehandler.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-_LIT(KCacheSubDir, "Cache\\");
-_LIT(KSysBin, "\\Sys\\Bin\\");
-_LIT(KBrowserPrefix, "4 " );
-_LIT(KFontsDir, "z:\\resource\\Fonts\\");
-
-#ifndef USE_SCHEMEHANDLER
-// copied from miutset.h, so we don't get a dependency into the app layer
-const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592
-const TUid KUidBrowser = { 0x10008D39 };
-
-template<class R>
-class QAutoClose
-{
-public:
- QAutoClose(R& aObj) : mPtr(&aObj) {}
- ~QAutoClose()
- {
- if (mPtr)
- mPtr->Close();
- }
- void Forget()
- {
- mPtr = 0;
- }
-private:
- QAutoClose(const QAutoClose&);
- QAutoClose& operator=(const QAutoClose&);
-private:
- R* mPtr;
-};
-
-#ifdef USE_DOCUMENTHANDLER
-class QS60DocumentHandler : public MAknServerAppExitObserver
-{
-public:
- QS60DocumentHandler() :docHandler(0) {}
-
- ~QS60DocumentHandler() {
- delete docHandler;
- }
-
- CDocumentHandler& documentHandler() {
- // In case user calls openUrl twice subsequently, before the first embedded app is closed
- // we use the same CDocumentHandler instance. Using same instance makes sure the first
- // launched embedded app is closed and latter one gets embedded to our app.
- // Using different instance would help only theoretically since user cannot interact with
- // several embedded apps at the same time.
- if(!docHandler) {
- QT_TRAP_THROWING(docHandler = CDocumentHandler::NewL());
- docHandler->SetExitObserver(this);
- }
- return *docHandler;
- }
-
-private: // From MAknServerAppExitObserver
- void HandleServerAppExit(TInt /*aReason*/) {
- delete docHandler;
- docHandler = 0;
- }
-
-private:
- CDocumentHandler* docHandler;
-};
-Q_GLOBAL_STATIC(QS60DocumentHandler, qt_s60_documenthandler);
-#endif
-
-static void handleMailtoSchemeLX(const QUrl &url)
-{
- // this function has many intermingled leaves and throws. Qt and Symbian objects do not have
- // destructor dependencies, and cleanup object is used to prevent cleanup stack dependency on stack.
- QString recipient = url.path();
- QString subject = url.queryItemValue(QLatin1String("subject"));
- QString body = url.queryItemValue(QLatin1String("body"));
- QString to = url.queryItemValue(QLatin1String("to"));
- QString cc = url.queryItemValue(QLatin1String("cc"));
- QString bcc = url.queryItemValue(QLatin1String("bcc"));
-
- // these fields might have comma separated addresses
- QStringList recipients = recipient.split(QLatin1String(","), QString::SkipEmptyParts);
- QStringList tos = to.split(QLatin1String(","), QString::SkipEmptyParts);
- QStringList ccs = cc.split(QLatin1String(","), QString::SkipEmptyParts);
- QStringList bccs = bcc.split(QLatin1String(","), QString::SkipEmptyParts);
-
- RSendAs sendAs;
- User::LeaveIfError(sendAs.Connect());
- QAutoClose<RSendAs> sendAsCleanup(sendAs);
-
- CSendAsAccounts* accounts = CSendAsAccounts::NewL();
- CleanupStack::PushL(accounts);
- sendAs.AvailableAccountsL(KUidMsgTypeSMTP, *accounts);
- TInt count = accounts->Count();
- CleanupStack::PopAndDestroy(accounts);
-
- if(!count) {
- // TODO: Task 259192: We should try to create account if count == 0
- // CSendUi would provide account creation service for us, but it requires ridicilous
- // capabilities: LocalServices NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData
- User::Leave(KErrNotSupported);
- } else {
- RSendAsMessage sendAsMessage;
- sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP);
- QAutoClose<RSendAsMessage> sendAsMessageCleanup(sendAsMessage);
-
-
- // Subject
- sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject));
-
- // Body
- sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body));
-
- // To
- foreach(QString item, recipients)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo);
-
- foreach(QString item, tos)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo);
-
- // Cc
- foreach(QString item, ccs)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc);
-
- // Bcc
- foreach(QString item, bccs)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc);
-
- // send the message
- sendAsMessage.LaunchEditorAndCloseL();
- // sendAsMessage is already closed
- sendAsMessageCleanup.Forget();
- }
-}
-
-static bool handleMailtoScheme(const QUrl &url)
-{
- TRAPD(err, QT_TRYCATCH_LEAVING(handleMailtoSchemeLX(url)));
- return err ? false : true;
-}
-
-static void handleOtherSchemesL(const TDesC& aUrl)
-{
- // Other schemes are at the moment passed to WEB browser
- HBufC* buf16 = HBufC::NewLC(aUrl.Length() + KBrowserPrefix.iTypeLength);
- buf16->Des().Copy(KBrowserPrefix); // Prefix used to launch correct browser view
- buf16->Des().Append(aUrl);
-
- TApaTaskList taskList(CEikonEnv::Static()->WsSession());
- TApaTask task = taskList.FindApp(KUidBrowser);
- if (task.Exists()){
- // Switch to existing browser instance
- task.BringToForeground();
- HBufC8* param8 = HBufC8::NewLC(buf16->Length());
- param8->Des().Append(buf16->Des());
- task.SendMessage(TUid::Uid( 0 ), *param8); // Uid is not used
- CleanupStack::PopAndDestroy(param8);
- } else {
- // Start a new browser instance
- RApaLsSession appArcSession;
- User::LeaveIfError(appArcSession.Connect());
- CleanupClosePushL<RApaLsSession>(appArcSession);
- TThreadId id;
- appArcSession.StartDocument(*buf16, KUidBrowser, id);
- CleanupStack::PopAndDestroy(); // appArcSession
- }
-
- CleanupStack::PopAndDestroy(buf16);
-}
-
-static bool handleOtherSchemes(const QUrl &url)
-{
- QString encUrl(QString::fromUtf8(url.toEncoded()));
- TPtrC urlPtr(qt_QString2TPtrC(encUrl));
- TRAPD( err, handleOtherSchemesL(urlPtr));
- return err ? false : true;
-}
-
-
-static void openDocumentL(const TDesC& aUrl)
-{
-#ifndef USE_DOCUMENTHANDLER
- // Start app associated to file MIME type by using RApaLsSession
- // Apparc base method cannot be used to open app in embedded mode,
- // but seems to be most stable way at the moment
- RApaLsSession appArcSession;
- User::LeaveIfError(appArcSession.Connect());
- CleanupClosePushL<RApaLsSession>(appArcSession);
- TThreadId id;
- // ESwitchFiles means do not start another instance
- // Leaves if file does not exist, leave is trapped in openDocument and false returned to user.
- User::LeaveIfError(appArcSession.StartDocument(aUrl, id,
- RApaLsSession::ESwitchFiles)); // ELaunchNewApp
- CleanupStack::PopAndDestroy(); // appArcSession
-#else
- // This is an alternative way to launch app associated to MIME type
- // CDocumentHandler also supports opening apps in embedded mode.
- TDataType temp;
- qt_s60_documenthandler()->documentHandler().OpenFileEmbeddedL(aUrl, temp);
-#endif
-}
-
-static bool launchWebBrowser(const QUrl &url)
-{
- if (!url.isValid())
- return false;
-
- if (url.scheme() == QLatin1String("mailto")) {
- return handleMailtoScheme(url);
- }
- return handleOtherSchemes( url );
-}
-
-static bool openDocument(const QUrl &file)
-{
- if (!file.isValid())
- return false;
-
- QString filePath = file.toLocalFile();
- filePath = QDir::toNativeSeparators(filePath);
- TPtrC filePathPtr(qt_QString2TPtrC(filePath));
- TRAPD(err, openDocumentL(filePathPtr));
- return err ? false : true;
-}
-
-#else //USE_SCHEMEHANDLER
-// The schemehandler component only exist in private SDK. This implementation
-// exist here just for convenience in case that we need to use it later on
-// The schemehandle based implementation is not yet tested.
-
-// The biggest advantage of schemehandler is that it can handle
-// wide range of schemes and is extensible by plugins
-static void handleUrlL(const TDesC& aUrl)
-{
- CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl);
- CleanupStack::PushL(schemeHandler);
- schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode
- CleanupStack::PopAndDestroy();
-}
-
-static bool handleUrl(const QUrl &url)
-{
- if (!url.isValid())
- return false;
-
- QString urlString(url.toEncoded());
- TPtrC urlPtr(qt_QString2TPtrC(urlString));
- TRAPD( err, handleUrlL(urlPtr));
- return err ? false : true;
-}
-
-static bool launchWebBrowser(const QUrl &url)
-{
- return handleUrl(url);
-}
-
-static bool openDocument(const QUrl &file)
-{
- return handleUrl(file);
-}
-
-#endif //USE_SCHEMEHANDLER
-
-// Common functions to all implementations
-
-static TDriveUnit exeDrive()
-{
- RProcess me;
- TFileName processFileName = me.FileName();
- TDriveUnit drive(processFileName);
- return drive;
-}
-
-static TDriveUnit writableExeDrive()
-{
- TDriveUnit drive = exeDrive();
- if (drive.operator TInt() == EDriveZ)
- return TDriveUnit(EDriveC);
- return drive;
-}
-
-static TPtrC writableDataRoot()
-{
- TDriveUnit drive = exeDrive();
- switch (drive.operator TInt()){
- case EDriveC:
- return PathInfo::PhoneMemoryRootPath();
- break;
- case EDriveE:
- return PathInfo::MemoryCardRootPath();
- break;
- case EDriveZ:
- // It is not possible to write on ROM drive ->
- // return phone mem root path instead
- return PathInfo::PhoneMemoryRootPath();
- break;
- default:
- return PathInfo::PhoneMemoryRootPath();
- break;
- }
-}
-
-QString QDesktopServices::storageLocation(StandardLocation type)
-{
- TFileName path;
-
- switch (type) {
- case DesktopLocation:
- qWarning("No desktop concept in Symbian OS");
- // But lets still use some feasible default
- path.Append(writableDataRoot());
- break;
- case DocumentsLocation:
- path.Append(writableDataRoot());
- break;
- case FontsLocation:
- path.Append(KFontsDir);
- break;
- case ApplicationsLocation:
- path.Append(exeDrive().Name());
- path.Append(KSysBin);
- break;
- case MusicLocation:
- path.Append(writableDataRoot());
- path.Append(PathInfo::SoundsPath());
- break;
- case MoviesLocation:
- path.Append(writableDataRoot());
- path.Append(PathInfo::VideosPath());
- break;
- case PicturesLocation:
- path.Append(writableDataRoot());
- path.Append(PathInfo::ImagesPath());
- break;
- case TempLocation:
- return QDir::tempPath();
- break;
- case HomeLocation:
- path.Append(writableDataRoot());
- //return QDir::homePath(); break;
- break;
- case DataLocation:
- qt_s60GetRFs().PrivatePath(path);
- path.Insert(0, writableExeDrive().Name());
- break;
- case CacheLocation:
- qt_s60GetRFs().PrivatePath(path);
- path.Insert(0, writableExeDrive().Name());
- path.Append(KCacheSubDir);
- break;
- default:
- // Lets use feasible default
- path.Append(writableDataRoot());
- break;
- }
-
- // Convert to cross-platform format and clean the path
- QString nativePath = QString::fromUtf16(path.Ptr(), path.Length());
- QString qtPath = QDir::fromNativeSeparators(nativePath);
- qtPath = QDir::cleanPath(qtPath);
-
- // Note: The storage location returned can be a directory that does not exist;
- // i.e., it may need to be created by the system or the user.
- return qtPath;
-}
-
-typedef QString (*LocalizerFunc)(QString&);
-
-static QString defaultLocalizedDirectoryName(QString&)
-{
- return QString();
-}
-
-QString QDesktopServices::displayName(StandardLocation type)
-{
- static LocalizerFunc ptrLocalizerFunc = NULL;
-
- if (!ptrLocalizerFunc) {
- ptrLocalizerFunc = reinterpret_cast<LocalizerFunc>
- (qt_resolveS60PluginFunc(S60Plugin_LocalizedDirectoryName));
- if (!ptrLocalizerFunc)
- ptrLocalizerFunc = &defaultLocalizedDirectoryName;
- }
-
- QString rawPath = storageLocation(type);
- return ptrLocalizerFunc(rawPath);
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp
deleted file mode 100644
index 783970ba82..0000000000
--- a/src/gui/util/qdesktopservices_win.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qsettings.h>
-#include <qdir.h>
-#include <private/qsystemlibrary_p.h>
-#include <qurl.h>
-#include <qstringlist.h>
-#include <qprocess.h>
-#include <qtemporaryfile.h>
-#include <qcoreapplication.h>
-
-#include <qt_windows.h>
-#include <shlobj.h>
-#if !defined(Q_OS_WINCE)
-# include <intshcut.h>
-#else
-# include <qguifunctions_wince.h>
-# if !defined(STANDARDSHELL_UI_MODEL)
-# include <winx.h>
-# endif
-#endif
-
-#ifndef CSIDL_MYMUSIC
-#define CSIDL_MYMUSIC 13
-#define CSIDL_MYVIDEO 14
-#endif
-
-#ifndef QT_NO_DESKTOPSERVICES
-
-QT_BEGIN_NAMESPACE
-
-static bool openDocument(const QUrl &file)
-{
- if (!file.isValid())
- return false;
- QString filePath = file.toLocalFile();
- if (filePath.isEmpty())
- filePath = file.toString();
- quintptr returnValue = (quintptr)ShellExecute(0, 0, (wchar_t*)filePath.utf16(), 0, 0, SW_SHOWNORMAL);
- return (returnValue > 32); //ShellExecute returns a value greater than 32 if successful
-}
-
-static QString expandEnvStrings(const QString &command)
-{
-#if defined(Q_OS_WINCE)
- return command;
-#else
- wchar_t buffer[MAX_PATH];
- if (ExpandEnvironmentStrings((wchar_t*)command.utf16(), buffer, MAX_PATH))
- return QString::fromWCharArray(buffer);
- else
- return command;
-#endif
-}
-
-static bool launchWebBrowser(const QUrl &url)
-{
- if (url.scheme() == QLatin1String("mailto")) {
- //Retrieve the commandline for the default mail client
- //the default key used below is the command line for the mailto: shell command
- DWORD bufferSize = sizeof(wchar_t) * MAX_PATH;
- long returnValue = -1;
- QString command;
-
- HKEY handle;
- LONG res;
- wchar_t keyValue[MAX_PATH] = {0};
- QString keyName(QLatin1String("mailto"));
-
- //Check if user has set preference, otherwise use default.
- res = RegOpenKeyEx(HKEY_CURRENT_USER,
- L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice",
- 0, KEY_READ, &handle);
- if (res == ERROR_SUCCESS) {
- returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
- if (!returnValue)
- keyName = QString::fromUtf16((const ushort*)keyValue);
- RegCloseKey(handle);
- }
- keyName += QLatin1String("\\Shell\\Open\\Command");
- res = RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle);
- if (res != ERROR_SUCCESS)
- return false;
-
- bufferSize = sizeof(wchar_t) * MAX_PATH;
- returnValue = RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
- if (!returnValue)
- command = QString::fromRawData((QChar*)keyValue, bufferSize);
- RegCloseKey(handle);
-
- if (returnValue)
- return false;
-
- command = expandEnvStrings(command);
- command = command.trimmed();
- //Make sure the path for the process is in quotes
- int index = -1 ;
- if (command[0]!= QLatin1Char('\"')) {
- index = command.indexOf(QLatin1String(".exe "), 0, Qt::CaseInsensitive);
- command.insert(index+4, QLatin1Char('\"'));
- command.insert(0, QLatin1Char('\"'));
- }
- //pass the url as the parameter
- index = command.lastIndexOf(QLatin1String("%1"));
- if (index != -1){
- command.replace(index, 2, url.toString());
- }
- //start the process
- PROCESS_INFORMATION pi;
- ZeroMemory(&pi, sizeof(pi));
- STARTUPINFO si;
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
-
- returnValue = CreateProcess(NULL, (wchar_t*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-
- if (!returnValue)
- return false;
-
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- return true;
- }
-
- if (!url.isValid())
- return false;
-
- if (url.scheme().isEmpty())
- return openDocument(url);
-
- quintptr returnValue = (quintptr)ShellExecute(0, 0, (wchar_t *)QString::fromUtf8(url.toEncoded().constData()).utf16(),
- 0, 0, SW_SHOWNORMAL);
- return (returnValue > 32);
-}
-
-QString QDesktopServices::storageLocation(StandardLocation type)
-{
- QString result;
-
-#ifndef Q_OS_WINCE
- QSystemLibrary library(QLatin1String("shell32"));
-#else
- QSystemLibrary library(QLatin1String("coredll"));
-#endif // Q_OS_WINCE
- typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
- static GetSpecialFolderPath SHGetSpecialFolderPath =
- (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW");
- if (!SHGetSpecialFolderPath)
- return QString();
-
- wchar_t path[MAX_PATH];
-
- switch (type) {
- case DataLocation:
-#if defined Q_WS_WINCE
- if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
-#else
- if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
-#endif
- result = QString::fromWCharArray(path);
- if (!QCoreApplication::organizationName().isEmpty())
- result = result + QLatin1String("\\") + QCoreApplication::organizationName();
- if (!QCoreApplication::applicationName().isEmpty())
- result = result + QLatin1String("\\") + QCoreApplication::applicationName();
- break;
-
- case DesktopLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_DESKTOPDIRECTORY, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case DocumentsLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case FontsLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_FONTS, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case ApplicationsLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_PROGRAMS, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case MusicLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_MYMUSIC, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case MoviesLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_MYVIDEO, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case PicturesLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_MYPICTURES, FALSE))
- result = QString::fromWCharArray(path);
- break;
-
- case CacheLocation:
- // Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache
- // location for everyone. Most applications seem to be using a
- // cache directory located in their AppData directory
- return storageLocation(DataLocation) + QLatin1String("\\cache");
-
- case QDesktopServices::HomeLocation:
- return QDir::homePath(); break;
-
- case QDesktopServices::TempLocation:
- return QDir::tempPath(); break;
-
- default:
- break;
- }
- return result;
-}
-
-QString QDesktopServices::displayName(StandardLocation type)
-{
- Q_UNUSED(type);
- return QString();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/gui/util/qdesktopservices_x11.cpp b/src/gui/util/qdesktopservices_x11.cpp
deleted file mode 100644
index e685bed0b9..0000000000
--- a/src/gui/util/qdesktopservices_x11.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdesktopservices.h"
-
-#ifndef QT_NO_DESKTOPSERVICES
-
-#include <qprocess.h>
-#include <qurl.h>
-#include <qdir.h>
-#include <qfile.h>
-#include <qtextstream.h>
-#include <private/qt_x11_p.h>
-#include <qcoreapplication.h>
-#include <stdlib.h>
-
-QT_BEGIN_NAMESPACE
-
-inline static bool launch(const QUrl &url, const QString &client)
-{
-#if !defined(QT_NO_PROCESS)
- return (QProcess::startDetached(client + QLatin1Char(' ') + QString::fromLatin1(url.toEncoded().constData())));
-#else
- return (::system((client + QLatin1Char(' ') + QString::fromLatin1(url.toEncoded().constData())).toLocal8Bit().constData()) != -1);
-#endif
-}
-
-static bool openDocument(const QUrl &url)
-{
- if (!url.isValid())
- return false;
-
- if (launch(url, QLatin1String("xdg-open")))
- return true;
-
- // Use the X11->desktopEnvironment value if X11 is non-NULL,
- // otherwise just attempt to launch command regardless of the desktop environment
- if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) {
- return true;
- } else {
- if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient exec")))
- return true;
- }
-
- if (launch(url, QLatin1String("firefox")))
- return true;
- if (launch(url, QLatin1String("mozilla")))
- return true;
- if (launch(url, QLatin1String("netscape")))
- return true;
- if (launch(url, QLatin1String("opera")))
- return true;
-
- return false;
-}
-
-static bool launchWebBrowser(const QUrl &url)
-{
- if (!url.isValid())
- return false;
- if (url.scheme() == QLatin1String("mailto"))
- return openDocument(url);
-
- if (launch(url, QLatin1String("xdg-open")))
- return true;
- if (launch(url, QString::fromLocal8Bit(getenv("DEFAULT_BROWSER"))))
- return true;
- if (launch(url, QString::fromLocal8Bit(getenv("BROWSER"))))
- return true;
-
- // Use the X11->desktopEnvironment value if X11 is non-NULL,
- // otherwise just attempt to launch command regardless of the desktop environment
- if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) {
- return true;
- } else {
- if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient openURL")))
- return true;
- }
-
- if (launch(url, QLatin1String("firefox")))
- return true;
- if (launch(url, QLatin1String("mozilla")))
- return true;
- if (launch(url, QLatin1String("netscape")))
- return true;
- if (launch(url, QLatin1String("opera")))
- return true;
- return false;
-}
-
-
-
-QString QDesktopServices::storageLocation(StandardLocation type)
-{
- if (type == QDesktopServices::HomeLocation)
- return QDir::homePath();
- if (type == QDesktopServices::TempLocation)
- return QDir::tempPath();
-
- // http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
- if (type == QDesktopServices::CacheLocation) {
- QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
- if (xdgCacheHome.isEmpty())
- xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
- xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName()
- + QLatin1Char('/') + QCoreApplication::applicationName();
- return xdgCacheHome;
- }
-
- if (type == QDesktopServices::DataLocation) {
- QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
- if (xdgDataHome.isEmpty())
- xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
- xdgDataHome += QLatin1String("/data/")
- + QCoreApplication::organizationName() + QLatin1Char('/')
- + QCoreApplication::applicationName();
- return xdgDataHome;
- }
-
- // http://www.freedesktop.org/wiki/Software/xdg-user-dirs
- QString xdgConfigHome = QLatin1String(qgetenv("XDG_CONFIG_HOME"));
- if (xdgConfigHome.isEmpty())
- xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
- QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));
- if (file.exists() && file.open(QIODevice::ReadOnly)) {
- QHash<QString, QString> lines;
- QTextStream stream(&file);
- // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
- QRegExp exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
- while (!stream.atEnd()) {
- QString line = stream.readLine();
- if (exp.indexIn(line) != -1) {
- QStringList lst = exp.capturedTexts();
- QString key = lst.at(1);
- QString value = lst.at(2);
- if (value.length() > 2
- && value.startsWith(QLatin1Char('\"'))
- && value.endsWith(QLatin1Char('\"')))
- value = value.mid(1, value.length() - 2);
- // Store the key and value: "DESKTOP", "$HOME/Desktop"
- lines[key] = value;
- }
- }
-
- QString key;
- switch (type) {
- case DesktopLocation: key = QLatin1String("DESKTOP"); break;
- case DocumentsLocation: key = QLatin1String("DOCUMENTS"); break;
- case PicturesLocation: key = QLatin1String("PICTURES"); break;
- case MusicLocation: key = QLatin1String("MUSIC"); break;
- case MoviesLocation: key = QLatin1String("VIDEOS"); break;
- default: break;
- }
- if (!key.isEmpty() && lines.contains(key)) {
- QString value = lines[key];
- // value can start with $HOME
- if (value.startsWith(QLatin1String("$HOME")))
- value = QDir::homePath() + value.mid(5);
- return value;
- }
- }
-
- QDir emptyDir;
- QString path;
- switch (type) {
- case DesktopLocation:
- path = QDir::homePath() + QLatin1String("/Desktop");
- break;
- case DocumentsLocation:
- path = QDir::homePath() + QLatin1String("/Documents");
- break;
- case PicturesLocation:
- path = QDir::homePath() + QLatin1String("/Pictures");
- break;
-
- case FontsLocation:
- path = QDir::homePath() + QLatin1String("/.fonts");
- break;
-
- case MusicLocation:
- path = QDir::homePath() + QLatin1String("/Music");
- break;
-
- case MoviesLocation:
- path = QDir::homePath() + QLatin1String("/Videos");
- break;
-
- case ApplicationsLocation:
- default:
- break;
- }
-
- return path;
-}
-
-QString QDesktopServices::displayName(StandardLocation type)
-{
- Q_UNUSED(type);
- return QString();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index db8e06555f..854964b784 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -4,7 +4,6 @@ HEADERS += \
util/qsystemtrayicon.h \
util/qcompleter.h \
util/qcompleter_p.h \
- util/qdesktopservices.h \
util/qsystemtrayicon_p.h \
util/qscroller.h \
util/qscroller_p.h \
@@ -19,7 +18,6 @@ HEADERS += \
SOURCES += \
util/qsystemtrayicon.cpp \
util/qcompleter.cpp \
- util/qdesktopservices.cpp \
util/qscroller.cpp \
util/qscrollerproperties.cpp \
util/qflickgesture.cpp \