source: trunk/src/gui/util/qdesktopservices_win.cpp@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 9.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <qsettings.h>
43#include <qdir.h>
44#include <private/qsystemlibrary_p.h>
45#include <qurl.h>
46#include <qstringlist.h>
47#include <qprocess.h>
48#include <qtemporaryfile.h>
49#include <qcoreapplication.h>
50
51#include <qt_windows.h>
52#include <shlobj.h>
53#if !defined(Q_OS_WINCE)
54# include <intshcut.h>
55#else
56# include <qguifunctions_wince.h>
57# if !defined(STANDARDSHELL_UI_MODEL)
58# include <winx.h>
59# endif
60#endif
61
62#ifndef CSIDL_MYMUSIC
63#define CSIDL_MYMUSIC 13
64#define CSIDL_MYVIDEO 14
65#endif
66
67#ifndef QT_NO_DESKTOPSERVICES
68
69QT_BEGIN_NAMESPACE
70
71static bool openDocument(const QUrl &file)
72{
73 if (!file.isValid())
74 return false;
75 QString filePath = file.toLocalFile();
76 if (filePath.isEmpty())
77 filePath = file.toString();
78 quintptr returnValue = (quintptr)ShellExecute(0, 0, (wchar_t*)filePath.utf16(), 0, 0, SW_SHOWNORMAL);
79 return (returnValue > 32); //ShellExecute returns a value greater than 32 if successful
80}
81
82static QString expandEnvStrings(const QString &command)
83{
84#if defined(Q_OS_WINCE)
85 return command;
86#else
87 wchar_t buffer[MAX_PATH];
88 if (ExpandEnvironmentStrings((wchar_t*)command.utf16(), buffer, MAX_PATH))
89 return QString::fromWCharArray(buffer);
90 else
91 return command;
92#endif
93}
94
95static bool launchWebBrowser(const QUrl &url)
96{
97 if (url.scheme() == QLatin1String("mailto")) {
98 //Retrieve the commandline for the default mail client
99 //the default key used below is the command line for the mailto: shell command
100 DWORD bufferSize = sizeof(wchar_t) * MAX_PATH;
101 long returnValue = -1;