diff options
author | Miguel Costa <miguel.costa@qt.io> | 2020-11-24 11:17:28 +0100 |
---|---|---|
committer | Miguel Costa <miguel.costa@qt.io> | 2020-11-27 11:51:40 +0000 |
commit | 0ecf997debd98b0a9b3d6e8e77c496f39cfaa2f2 (patch) | |
tree | 9dc32e6e1abd83087c579d394ae5fb2b55604c7d | |
parent | 58c12242ad4f80cfd65f22945d51a31398b1f5b3 (diff) |
Remove AppWrapper and default editors
The AppWrapper and default editors project files are no longer needed.
Task-number: QTVSADDINBUG-734
Task-number: QTVSADDINBUG-735
Change-Id: I19a5d705502180288677e5bb164aec415749f6e9
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
26 files changed, 3 insertions, 1702 deletions
@@ -278,7 +278,6 @@ src/config/12.0/source.extension.vsixmanifest src/config/14.0/source.extension.vsixmanifest src/config/15.0/source.extension.vsixmanifest src/config/16.0/source.extension.vsixmanifest -src/qtappwrapper/Properties/AssemblyInfo.tt.cs src/qtprojectlib/Properties/AssemblyInfo.tt.cs src/qttemplates/console/Properties/AssemblyInfo.tt.cs src/qttemplates/designer/Properties/AssemblyInfo.tt.cs diff --git a/src/QtVsTools.sln b/src/QtVsTools.sln index 65c268d8..5117750c 100644 --- a/src/QtVsTools.sln +++ b/src/QtVsTools.sln @@ -1,14 +1,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30611.23 MinimumVisualStudioVersion = 12.0.40629.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visualizer", "Visualizer", "{56BEEACF-C297-483D-9E64-C0A7C3B7680E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Templates", "Templates", "{D73514C8-019E-44FB-8D42-F1FD52C1FD72}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QtAppWrapper", "qtappwrapper\QtAppWrapper.csproj", "{6E591BB2-3C81-4AB5-B3B0-096045754C3A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QtProjectLib", "qtprojectlib\QtProjectLib.csproj", "{FAA69518-2FEB-4954-9D2C-E7BD6121EA9C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QtVsTools", "qtvstools\QtVsTools.csproj", "{FD7A42DB-8692-4FBE-AC50-F70AF423275B}" @@ -81,7 +79,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "qt", "qt", "{62102FDD-016A- qttmlanguage\qt\pri.pro.tmLanguage = qttmlanguage\qt\pri.pro.tmLanguage EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vsqml", "vsqml\vsqml.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VsQml", "vsqml\vsqml.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "T4 Templates", "T4 Templates", "{24A01B54-CE41-4559-8418-0723F8DF723F}" ProjectSection(SolutionItems) = preProject @@ -135,18 +133,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Debug|x64.ActiveCfg = Debug|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Debug|x64.Build.0 = Debug|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Debug|x86.ActiveCfg = Debug|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Debug|x86.Build.0 = Debug|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Release|Any CPU.Build.0 = Release|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Release|x64.ActiveCfg = Release|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Release|x64.Build.0 = Release|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Release|x86.ActiveCfg = Release|Any CPU - {6E591BB2-3C81-4AB5-B3B0-096045754C3A}.Release|x86.Build.0 = Release|Any CPU {FAA69518-2FEB-4954-9D2C-E7BD6121EA9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FAA69518-2FEB-4954-9D2C-E7BD6121EA9C}.Debug|Any CPU.Build.0 = Debug|Any CPU {FAA69518-2FEB-4954-9D2C-E7BD6121EA9C}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/src/config/12.0/source.extension.vsixmanifest_TT b/src/config/12.0/source.extension.vsixmanifest_TT index 9f6f0870..f8870814 100644 --- a/src/config/12.0/source.extension.vsixmanifest_TT +++ b/src/config/12.0/source.extension.vsixmanifest_TT @@ -70,9 +70,6 @@ Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" /> <Asset - Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtAppWrapper" - Path="|QtAppWrapper|" AssemblyName="|QtAppWrapper;AssemblyName|" /> - <Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtVsTools.Wizards" Path="|QtVsTools.Wizards|" AssemblyName="|QtVsTools.Wizards;AssemblyName|" /> <Asset diff --git a/src/config/14.0/source.extension.vsixmanifest_TT b/src/config/14.0/source.extension.vsixmanifest_TT index 43884ef3..51cefd4d 100644 --- a/src/config/14.0/source.extension.vsixmanifest_TT +++ b/src/config/14.0/source.extension.vsixmanifest_TT @@ -70,9 +70,6 @@ Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" /> <Asset - Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtAppWrapper" - Path="|QtAppWrapper|" AssemblyName="|QtAppWrapper;AssemblyName|" /> - <Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtVsTools.Wizards" Path="|QtVsTools.Wizards|" AssemblyName="|QtVsTools.Wizards;AssemblyName|" /> <Asset diff --git a/src/config/15.0/source.extension.vsixmanifest_TT b/src/config/15.0/source.extension.vsixmanifest_TT index 2a9fbeba..ed48ec58 100644 --- a/src/config/15.0/source.extension.vsixmanifest_TT +++ b/src/config/15.0/source.extension.vsixmanifest_TT @@ -78,9 +78,6 @@ Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" /> <Asset - Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtAppWrapper" - Path="|QtAppWrapper|" AssemblyName="|QtAppWrapper;AssemblyName|" /> - <Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtVsTools.Wizards" Path="|QtVsTools.Wizards|" AssemblyName="|QtVsTools.Wizards;AssemblyName|" /> <Asset diff --git a/src/config/16.0/source.extension.vsixmanifest_TT b/src/config/16.0/source.extension.vsixmanifest_TT index aa74d431..4e451897 100644 --- a/src/config/16.0/source.extension.vsixmanifest_TT +++ b/src/config/16.0/source.extension.vsixmanifest_TT @@ -71,9 +71,6 @@ Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" /> <Asset - Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtAppWrapper" - Path="|QtAppWrapper|" AssemblyName="|QtAppWrapper;AssemblyName|" /> - <Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="QtVsTools.Wizards" Path="|QtVsTools.Wizards|" AssemblyName="|QtVsTools.Wizards;AssemblyName|" /> <Asset diff --git a/src/qrceditor/mainwindow.cpp b/src/qrceditor/mainwindow.cpp index 9e7aba07..8a8d17a8 100644 --- a/src/qrceditor/mainwindow.cpp +++ b/src/qrceditor/mainwindow.cpp @@ -135,7 +135,6 @@ void MainWindow::slotSave() m_qrcEditor->setFileName(fileName); if (m_qrcEditor->save()) { statusBar()->showMessage(tr("%1 written").arg(fileName)); - sendFileNameToQtAppWrapper(); } else { statusBar()->showMessage(tr("Unable to write %1.").arg(fileName)); m_qrcEditor->setFileName(oldFileName); @@ -182,48 +181,3 @@ int MainWindow::fileChangedDialog() message.setDefaultButton(QMessageBox::Yes); return message.exec(); } - -void MainWindow::sendFileNameToQtAppWrapper() -{ - if (m_qtAppWrapperPath.isNull()) { - // Try to find qtappwrapper.exe - m_qtAppWrapperPath = QCoreApplication::applicationDirPath(); - m_qtAppWrapperPath += QLatin1String("/qtappwrapper.exe"); - if (!QFile::exists(m_qtAppWrapperPath)) { - m_qtAppWrapperPath.clear(); - qWarning("Can't locate qtappwrapper.exe."); - return; - } - } - - if (m_devenvPIDArg.isNull()) { - HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hSnapShot == INVALID_HANDLE_VALUE) { - qWarning("CreateToolhelp32Snapshot failed."); - return; - } - BOOL bSuccess; - const DWORD dwThisPID = QCoreApplication::applicationPid(); - PROCESSENTRY32 processEntry; - processEntry.dwSize = sizeof(processEntry); - bSuccess = Process32First(hSnapShot, &processEntry); - while (bSuccess) { - if (processEntry.th32ProcessID == dwThisPID) { - m_devenvPIDArg = QLatin1String("-pid "); - m_devenvPIDArg += QString::number(processEntry.th32ParentProcessID); - break; - } - bSuccess = Process32Next(hSnapShot, &processEntry); - } - CloseHandle(hSnapShot); - - if (m_devenvPIDArg.isNull()) { - qWarning("Couldn't determine parent's process id."); - return; - } - } - - if (!QProcess::startDetached(m_qtAppWrapperPath, QStringList() << m_qrcEditor->fileName() << m_devenvPIDArg)) { - qWarning("Couldn't start qtappwrapper.exe."); - } -} diff --git a/src/qrceditor/mainwindow.h b/src/qrceditor/mainwindow.h index b56c72f3..6d25bd27 100644 --- a/src/qrceditor/mainwindow.h +++ b/src/qrceditor/mainwindow.h @@ -56,11 +56,9 @@ private slots: private: int fileChangedDialog(); - void sendFileNameToQtAppWrapper(); private: SharedTools::QrcEditor *m_qrcEditor; - QString m_qtAppWrapperPath; QString m_devenvPIDArg; }; diff --git a/src/qtappwrapper/DefaultEditorsHandler.cs b/src/qtappwrapper/DefaultEditorsHandler.cs deleted file mode 100644 index 498ae58f..00000000 --- a/src/qtappwrapper/DefaultEditorsHandler.cs +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.Net; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Text; - -namespace QtAppWrapper -{ - static class DefaultEditorsHandler - { - private static string GetParentProcessID(string[] args) - { - Debug.WriteLine("Entering function GetParentPID()."); - - var ppid = "-1"; - try { - if (args.Length == 1) { // the first argument is the file name - var hwnd = NativeMethods.CreateToolhelp32Snapshot(NativeMethods - .TH32CS_SNAPPROCESS, 0); - if (hwnd == NativeMethods.INVALID_HANDLE_VALUE) - return ppid; - - var entry = new NativeMethods.PROCESSENTRY32(); - entry.dwSize = Marshal.SizeOf(typeof(NativeMethods.PROCESSENTRY32)); - - if (NativeMethods.Process32First(hwnd, ref entry)) { - var parentPid = 0; - do { - var currentPid = Process.GetCurrentProcess().Id; - if (currentPid == entry.th32ProcessID) - parentPid = entry.th32ParentProcessID; - } while (parentPid == 0 && NativeMethods.Process32Next(hwnd, ref entry)); - - if (parentPid > 0) { - ppid = Process.GetProcessById(parentPid).Id.ToString(CultureInfo - .InvariantCulture); - } - } - NativeMethods.CloseHandle(hwnd); - } else if (args.Length >= 1 && args[1].StartsWith("-pid ", StringComparison.Ordinal)) { - ppid = args[1].Substring("-pid ".Length); - } - return ppid; - } finally { - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, - "Leaving function GetParentPID() with PID: '{0}'.", ppid)); - } - } - - public static void SendFileNameToDefaultEditorsServer(string[] args) - { - Debug.WriteLine("Entering function SendFileNameToDefaultEditorsServer()."); - Debug.WriteLine("Argument:"); - Debug.Indent(); - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "string[]: '{0}'", - string.Join(Environment.NewLine, args))); - Debug.Unindent(); - - var fileName = args[0]; - var processId = GetParentProcessID(args); - - try { - using (var client = new TcpClient()) { - var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 12015); - try { - client.Connect(serverEndPoint); - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } - - if (!client.Connected) { - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, - "Could not connect to server. Expected server address: '{0}'.", - serverEndPoint)); - return; - } - - try { - var encoder = new UnicodeEncoding(); - var buffer = encoder.GetBytes(processId + " " + fileName + "\n"); - - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, - "Trying to send file name: '{0}' and process ID: '{1}'.", fileName, - processId)); - - var stream = client.GetStream(); - stream.Write(buffer, 0, buffer.Length); - stream.Flush(); - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } - - if (client.Connected) - client.GetStream().Close(); - } - } finally { - Debug.WriteLine("Leaving function SendFileNameToDefaultEditorsServer()."); - } - } - } -} diff --git a/src/qtappwrapper/DefaultEditorsServer.cs b/src/qtappwrapper/DefaultEditorsServer.cs deleted file mode 100644 index 89ab7fa7..00000000 --- a/src/qtappwrapper/DefaultEditorsServer.cs +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Net; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; - -namespace QtAppWrapper -{ - class DefaultEditorsServer - { - public static void StartListen() - { - Instance = new DefaultEditorsServer(); - } - - public static DefaultEditorsServer Instance - { - get; private set; - } - - private volatile bool aboutToExit; - private Thread listenThread; - private TcpListener tcpListener; - private readonly List<TcpClient> clientList = new List<TcpClient>(); - private static readonly byte[] helloMessage = { 0x48, 0x45, 0x4C, 0x4C, 0x4F }; - - private DefaultEditorsServer() - { - Debug.WriteLine("Entering function DefaultEditorsServer()."); - - tcpListener = new TcpListener(IPAddress.Loopback, 12015); - listenThread = new Thread(ListenForClients); - listenThread.Start(); - - // The server will run for ever if no connection from an VSIX extension occurs. - // So we'll check after a certain time, if there's something in the client list. - var timer = new System.Timers.Timer(60000); - var handle = GCHandle.Alloc(timer); - timer.Elapsed += (sender, args) => - { - Debug.WriteLine("Entering function Elapsed()."); - Debug.WriteLine("Arguments:"); - Debug.Indent(); - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, - "Object: '{0}', EventArgs: '{1}'", sender, args)); - Debug.Unindent(); - - timer.Stop(); - handle.Free(); - timer.Dispose(); - try { - lock (clientList) { - if (clientList.Count > 0) - return; - } - Shutdown(); - } finally { - Debug.WriteLine("Leaving function Elapsed()."); - } - }; - timer.Start(); - - Debug.WriteLine("Leaving function DefaultEditorsServer()."); - } - - private void Shutdown() - { - Debug.WriteLine("Entering function Shutdown()."); - - aboutToExit = true; - tcpListener.Stop(); - lock (clientList) { - foreach (var client in clientList) { - if (client != null) { - if (client.Connected) - client.GetStream().Close(); - client.Close(); - } - } - } - listenThread.Join(1000); - Environment.Exit(0); - - Debug.WriteLine("Leaving function Shutdown()."); - } - - private void ListenForClients() - { - Debug.WriteLine("Entering function ListenForClients()."); - - try { - try { - tcpListener.Start(); - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - return; - } - - while (!aboutToExit) { - try { - if (!tcpListener.Pending()) { - Thread.Sleep(250); - continue; - } - - //blocks until a client has connected to the server - var client = tcpListener.AcceptTcpClient(); - if (aboutToExit) - break; - - var message = new byte[4096]; - var stream = client.GetStream(); - var bytesRead = stream.Read(message, 0, message.Length); - if (MessageReceived(message, bytesRead) == MessageType.Hello) { - lock (clientList) - clientList.Add(client); - - // Create a thread to handle communication with connected client. - var clientThread = new Thread(WatchConnection); - clientThread.Start(client); - } else { - BroadcastMessageToVsixClients(message, bytesRead); - stream.Close(); - client.Close(); - } - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } - } - } finally { - Debug.WriteLine("Leaving function ListenForClients()."); - } - } - - private void WatchConnection(object client) - { - Debug.WriteLine("Entering function WatchConnection()."); - Debug.WriteLine("Argument:"); - Debug.Indent(); - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "object: '{0}'", client)); - Debug.Unindent(); - - try { - var tcpClient = client as TcpClient; - var stream = tcpClient.GetStream(); - - try { - var buffer = new byte[1024]; - stream.Read(buffer, 0, buffer.Length); - } catch (System.IO.IOException e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } - - lock (clientList) - clientList.Remove(tcpClient); - - tcpClient.Close(); - stream.Close(); - - if (clientList.Count == 0) - Shutdown(); - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } finally { - Debug.WriteLine("Leaving function WatchConnection()."); - } - } - - private static MessageType MessageReceived(byte[] message, int length) - { - Debug.WriteLine("Entering function MessageReceived()."); - Debug.WriteLine("Arguments:"); - Debug.Indent(); - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "byte: '{0}', int: '{1}'", - new UnicodeEncoding().GetString(message, 0, length).Replace("\n", ""), length)); - Debug.Unindent(); - - try { - if (length < helloMessage.Length) - return MessageType.Data; - - for (var i = 0; i < helloMessage.Length; ++i) { - if (message[i] != helloMessage[i]) - return MessageType.Data; - } - } finally { - Debug.WriteLine("Leaving function MessageReceived()."); - } - return MessageType.Hello; - } - - private void BroadcastMessageToVsixClients(byte[] data, int dataSize) - { - Debug.WriteLine("Entering function BroadcastMessageToVsixClients()."); - Debug.WriteLine("Arguments:"); - Debug.Indent(); - Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "byte: '{0}', int: '{1}'", - new UnicodeEncoding().GetString(data, 0, dataSize).Replace("\n", ""), dataSize)); - Debug.Unindent(); - - try { - lock (clientList) { - foreach (var client in clientList) { - try { - var clientStream = client.GetStream(); - clientStream.Write(data, 0, dataSize); - clientStream.Flush(); - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } - } - } - } finally { - Debug.WriteLine("Leaving function BroadcastMessageToVsixClients()."); - } - } - } -} diff --git a/src/qtappwrapper/MessageType.cs b/src/qtappwrapper/MessageType.cs deleted file mode 100644 index 087b5689..00000000 --- a/src/qtappwrapper/MessageType.cs +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -namespace QtAppWrapper -{ - enum MessageType - { - Data, - Hello - } -} diff --git a/src/qtappwrapper/NativeMethods.cs b/src/qtappwrapper/NativeMethods.cs deleted file mode 100644 index 9d53ef0d..00000000 --- a/src/qtappwrapper/NativeMethods.cs +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using System; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; - -namespace QtAppWrapper -{ - internal static class NativeMethods - { - [StructLayout(LayoutKind.Sequential)] - public struct PROCESSENTRY32 - { - public int dwSize; - public uint cntUsage; - public uint th32ProcessID; - public IntPtr th32DefaultHeapID; - public uint th32ModuleID; - public uint cntThreads; - public int th32ParentProcessID; - public int pcPriClassBase; - public uint dwFlags; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] - public string szExeFile; - } - - internal const int TH32CS_SNAPPROCESS = 0x00000002; - internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); - - [ResourceExposure(ResourceScope.Process)] - [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - internal static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID); - - [ResourceExposure(ResourceScope.None)] - [return: MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", SetLastError = true)] - internal static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe); - - [ResourceExposure(ResourceScope.None)] - [return: MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", SetLastError = true)] - internal static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe); - - [ResourceExposure(ResourceScope.None)] - [return: MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)] - public static extern bool CloseHandle(IntPtr handle); - } -} diff --git a/src/qtappwrapper/Program.cs b/src/qtappwrapper/Program.cs deleted file mode 100644 index 83292d20..00000000 --- a/src/qtappwrapper/Program.cs +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using System; -using System.Diagnostics; - -namespace QtAppWrapper -{ - /// <summary> - /// This application serves two different purposes. The first one is to run as a standalone - /// server application. The second purpose is to be registered by a VSIX instance as default - /// handler for .ui and .ts files. Once a user starts editing a file inside VS, the default - /// registered file handler (this application) is started as new instance with the file name - /// as argument. We now simply forward the file and PID to the running server, that will then - /// broadcast the incoming data to connected VSIX instances. The VSIX instance matching the - /// PID will now lookup the right Qt Designer or Qt Linguist and open the corresponding file. - /// </summary> - static class Program - { - [STAThread] - static void Main(string[] args) - { - Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); - Debug.AutoFlush = true; - Debug.WriteLine("Entering Main function."); - Debug.Indent(); - - try { - switch (args.Length) { - case 0: - // Try to start the server and begin to listen. - Debug.WriteLine("Starting the server instance."); - DefaultEditorsServer.StartListen(); - break; - default: - // Forward incoming arguments to the running server instance. - Debug.WriteLine("Sending file name to server instance."); - DefaultEditorsHandler.SendFileNameToDefaultEditorsServer(args); - break; - } - } catch (Exception e) { - Debug.WriteLine("Exception thrown:"); - Debug.Indent(); - Debug.WriteLine(e.Message); - Debug.Unindent(); - } - - Debug.Unindent(); - Debug.WriteLine("Leaving Main function"); - } - } -} diff --git a/src/qtappwrapper/Properties/AssemblyInfo.cs b/src/qtappwrapper/Properties/AssemblyInfo.cs deleted file mode 100644 index 45d75415..00000000 --- a/src/qtappwrapper/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -**************************************************************************** -<#@output extension="tt.cs" #> -<#@include file="$(SolutionDir)\version.tt" #> -** <#=WARNING_GENERATED_FILE#> -****************************************************************************/ - -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Qt App Wrapper")] -[assembly: AssemblyDescription("The Qt Visual Studio Tools allow developers to use the standard development environment without having to worry about any Qt-related build steps or tools.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("The Qt Company Ltd.")] -[assembly: AssemblyProduct("Qt Visual Studio Tools")] -[assembly: AssemblyCopyright("Copyright (C) 2016-2017 The Qt Company Ltd.")] -[assembly: AssemblyTrademark("The Qt Company Ltd. Qt and their respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("12863c1f-a32b-4c35-b860-118ba72400dc")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("<#=QT_VS_TOOLS_VERSION_ASSEMBLY#>")] -[assembly: AssemblyFileVersion("<#=QT_VS_TOOLS_VERSION_ASSEMBLY_FILE#>")] diff --git a/src/qtappwrapper/QtAppWrapper.csproj b/src/qtappwrapper/QtAppWrapper.csproj deleted file mode 100644 index cb9d59e9..00000000 --- a/src/qtappwrapper/QtAppWrapper.csproj +++ /dev/null @@ -1,75 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="$(VisualStudioVersion)" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{6E591BB2-3C81-4AB5-B3B0-096045754C3A}</ProjectGuid> - <OutputType Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">WinExe</OutputType> - <OutputType Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">Exe</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>QtAppWrapper</RootNamespace> - <AssemblyName>QtAppWrapper</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup> - <ApplicationIcon>QtAppWrapper.ico</ApplicationIcon> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - </ItemGroup> - <ItemGroup> - <Compile Include="DefaultEditorsHandler.cs" /> - <Compile Include="DefaultEditorsServer.cs" /> - <Compile Include="MessageType.cs" /> - <Compile Include="NativeMethods.cs" /> - <Compile Include="Program.cs" /> - <T4Template Include="Properties\AssemblyInfo.cs"> - <Generator>TextTemplatingFileGenerator</Generator> - <OutputFile>Properties\AssemblyInfo.tt.cs</OutputFile> - <DependsOn>$(SolutionDir)\version.tt;$(SolutionDir)\common.tt</DependsOn> - <LastGenOutput>AssemblyInfo.tt.cs</LastGenOutput> - </T4Template> - <Compile Include="Properties\AssemblyInfo.tt.cs"> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - <DependentUpon>AssemblyInfo.cs</DependentUpon> - </Compile> - </ItemGroup> - <ItemGroup> - <Content Include="QtAppWrapper.ico" /> - </ItemGroup> - <ItemGroup> - <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <Import Project="$(SolutionDir)\transform.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> diff --git a/src/qtappwrapper/QtAppWrapper.ico b/src/qtappwrapper/QtAppWrapper.ico Binary files differdeleted file mode 100644 index 1c4fb80d..00000000 --- a/src/qtappwrapper/QtAppWrapper.ico +++ /dev/null diff --git a/src/qtvstools/DefaultEditor.cs b/src/qtvstools/DefaultEditor.cs deleted file mode 100644 index 145bd1f9..00000000 --- a/src/qtvstools/DefaultEditor.cs +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -namespace QtVsTools -{ - static class DefaultEditor - { - public enum Kind - { - Ts, - Ui - } - } -} diff --git a/src/qtvstools/DefaultEditorsBase.cs b/src/qtvstools/DefaultEditorsBase.cs deleted file mode 100644 index b1a97b4e..00000000 --- a/src/qtvstools/DefaultEditorsBase.cs +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using Microsoft.Win32; - -namespace QtVsTools -{ - // Base class to support writing default editor values to registry - public class DefaultEditorsBase - { - private const string registryBasePath = @"SOFTWARE\Microsoft\VisualStudio\{0}"; - private const string newProjectTemplates = @"\NewProjectTemplates\TemplateDirs\{0}\/1"; - - private const string linguist = @"Qt Linguist"; - private const string designer = @"Qt Designer"; - private const string qrcEditor = @"Qt Resource Editor"; - - private readonly string guid; - private readonly string appWrapper; - private readonly string qrcEditorName; - - /// <summary> - /// Write default editor values to registry for VS 2013 if add-in is installed. Applies - /// both to Qt4 and Qt5 version of the add-in. TODO: Remove if we drop Visual Studio 2013. - /// </summary> - public void WriteAddinRegistryValues() - { - var basePath = string.Format(registryBasePath, @"12.0"); - var projectTemplates = basePath + string.Format(newProjectTemplates, guid); - - var addinInstallPath = GetAddinInstallPath(GetCUKey(projectTemplates, false)); - if (string.IsNullOrEmpty(addinInstallPath)) - addinInstallPath = GetAddinInstallPath(GetLMKey(projectTemplates, false)); - WriteRegistryValues(basePath, addinInstallPath); - } - - /// <summary> - /// Write default editor values to registry for Visual Studio 2013 and above. Uses the VSIX - /// install path. - /// </summary> - public void WriteVsixRegistryValues(Vsix vsixInstance) - { - if (vsixInstance.Dte != null) { - var basePath = string.Format(registryBasePath, vsixInstance.Dte.Version) -#if DEBUG - + @"Exp" -#endif - ; - WriteRegistryValues(basePath, vsixInstance.PkgInstallPath); - } - } - - protected DefaultEditorsBase(string uid, string wrapper, string editor) - { - guid = uid; - appWrapper = wrapper; - qrcEditorName = editor; - } - - // Get add-in installation path using a registry key - private static string GetAddinInstallPath(RegistryKey key) - { - if (key == null) - return null; - - var templatesDirPath = key.GetValue(@"TemplatesDir") as string; - if (string.IsNullOrEmpty(templatesDirPath)) - return null; - - return templatesDirPath.Substring(0, templatesDirPath.IndexOf(@"\projects\", - System.StringComparison.Ordinal)); - } - - // Get/create registry key under HKCU - private static RegistryKey GetCUKey(string key_path, bool writable) - { - var key = Registry.CurrentUser.OpenSubKey(key_path, writable); - if (key == null && writable) - key = Registry.CurrentUser.CreateSubKey(key_path); - return key; - } - - // Get/create registry key under HKLM - private static RegistryKey GetLMKey(string key_path, bool writable) - { - var key = Registry.LocalMachine.OpenSubKey(key_path, writable); - if (key == null && writable) - key = Registry.LocalMachine.CreateSubKey(key_path); - return key; - } - - private void WriteRegistryValues(string basePath, string installPath) - { - if (string.IsNullOrEmpty(basePath) || string.IsNullOrEmpty(installPath)) - return; - - installPath += @"\"; - WriteCustomTypeEditor(basePath + @"\Default Editors\ts", linguist); - var key = GetCUKey(basePath + @"\Default Editors\ts\" + linguist, true); - key.SetValue(@"", installPath + appWrapper); - - WriteCustomTypeEditor(basePath + @"\Default Editors\ui", designer); - key = GetCUKey(basePath + @"\Default Editors\ui\" + designer, true); - key.SetValue(@"", installPath + appWrapper); - - WriteCustomTypeEditor(basePath + @"\Default Editors\qrc", qrcEditor); - key = GetCUKey(basePath + @"\Default Editors\qrc\" + qrcEditor, true); - key.SetValue(@"", installPath + qrcEditorName); - } - - private static void WriteCustomTypeEditor(string path, string customEditor) - { - var key = Registry.CurrentUser.OpenSubKey(path, true); - if (key == null) { - key = Registry.CurrentUser.CreateSubKey(path); - key.SetValue(@"Custom", customEditor); - key.SetValue(@"Type", 0x00000002, RegistryValueKind.DWord); - } - } - } - - // Default editor handling for Qt4 add-in - - // Default editor handling for Qt5 add-in - - // Default editor handling for Qt VS Tools -} diff --git a/src/qtvstools/DefaultEditorsClient.cs b/src/qtvstools/DefaultEditorsClient.cs deleted file mode 100644 index 0a4ef075..00000000 --- a/src/qtvstools/DefaultEditorsClient.cs +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using QtProjectLib; -using System; -using System.Collections.Concurrent; -using System.Diagnostics; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; - -namespace QtVsTools -{ - class DefaultEditorsClient - { - public static DefaultEditorsClient Instance - { - get; private set; - } - - public static void Initialize(DteEventsHandler handler) - { - Instance = new DefaultEditorsClient(handler); - } - - public void Listen() - { - listenForBroadcastThread.Start(); - handleBroadcastMessageThread.Start(); - } - - public void Shutdown() - { - aboutToExit = true; - autoResetEvent.Set(); - - if (listenForBroadcastThread.IsAlive) { - TerminateClient(); - if (!listenForBroadcastThread.Join(1000)) - listenForBroadcastThread.Abort(); - } - - if (handleBroadcastMessageThread.IsAlive && !handleBroadcastMessageThread.Join(1000)) - handleBroadcastMessageThread.Abort(); - } - - private TcpClient client; - private DteEventsHandler handler; - private volatile bool aboutToExit; - private Thread listenForBroadcastThread; - private Thread handleBroadcastMessageThread; - - private const int qtAppWrapperPort = 12015; - private readonly AutoResetEvent autoResetEvent = new AutoResetEvent(false); - private static readonly byte[] helloMessage = { 0x48, 0x45, 0x4C, 0x4C, 0x4F }; - private readonly ConcurrentQueue<string> messageQueue = new ConcurrentQueue<string>(); - - private DefaultEditorsClient(DteEventsHandler handler) - { - this.handler = handler; - listenForBroadcastThread = new Thread(ListenForBroadcastMessage) - { - Name = "ListenForBroadcastMessage" - }; - handleBroadcastMessageThread = new Thread(HandleBroadcastMessage) - { - Name = "HandleBroadcastMessage" - }; - } - - private void HandleBroadcastMessage() - { - while (!aboutToExit) { - autoResetEvent.WaitOne(); - if (aboutToExit) - break; - - string message; - while (!aboutToExit && messageQueue.TryDequeue(out message)) { - if (HelperFunctions.IsQrcFile(message)) - handler.OnQRCFileSaved(message); - else if (message.StartsWith("Autotests:set", StringComparison.Ordinal)) { -#if DEBUG - // Messageformat from Autotests is Autotests:set<dir>:<value> - // where dir is MocDir, RccDir or UicDir - - //remove Autotests:set - message = message.Substring(13); - - var dir = message.Remove(6); - var value = message.Substring(7); - - handler.setDirectory(dir, value); -#endif - } else { - DefaultEditorsHandler.Instance.StartEditor(message); - } - } - } - } - - private void ListenForBroadcastMessage() - { - if (Vsix.Instance.AppWrapperPath == null) { - Messages.DisplayCriticalErrorMessage("QtAppWrapper can't be found in the " - + "installation directory."); aboutToExit = true; return; - } - - Process qtAppWrapperProcess = null; - try { - qtAppWrapperProcess = new Process(); - qtAppWrapperProcess.StartInfo.FileName = Vsix.Instance.AppWrapperPath; - - var firstIteration = true; - while (!aboutToExit) { - try { - if (!firstIteration && qtAppWrapperProcess.HasExited) - qtAppWrapperProcess.Close(); - } catch { } finally { - firstIteration = false; - qtAppWrapperProcess.Start(); - } - - var connectionAttempts = 0; - if (!aboutToExit) { - client = new TcpClient(); - while (!aboutToExit && !client.Connected && connectionAttempts < 10) { - try { - client.Connect(IPAddress.Loopback, qtAppWrapperPort); - if (!client.Connected) - Thread.Sleep(1000); - } catch { - Thread.Sleep(1000); - } finally { - ++connectionAttempts; - } - } - } - - if (connectionAttempts >= 10) { - Messages.DisplayErrorMessage(SR.GetString("CouldNotConnectToAppwrapper", - qtAppWrapperPort)); - aboutToExit = true; - } - - if (!aboutToExit) { - var stream = client.GetStream(); - stream.Write(helloMessage, 0, helloMessage.Length); - stream.Flush(); // say hello to qt application wrapper - } - - var data = new byte[4096]; - while (!aboutToExit) { - try { - var bytesRead = 0; - try { - // blocks until the default editors server sends a message - var stream = client.GetStream(); - bytesRead = stream.Read(data, 0, 4096); - } catch { - // A socket error has occurred, probably because the QtAppWrapper - // has been terminated. Break and then try to restart the QtAppWrapper. - break; - } - - if (bytesRead == 0) - break; // The server has disconnected from us. - - // data has successfully been received - var decodedData = new UnicodeEncoding().GetString(data, 0, bytesRead); - var messages = decodedData.Split(new[] { '\n' }, - StringSplitOptions.RemoveEmptyEntries); - - foreach (var message in messages) { - var index = message.IndexOf(' '); - var requestedPid = Convert.ToInt32(message.Substring(0, index)); - if (requestedPid == Process.GetCurrentProcess().Id) - messageQueue.Enqueue(message.Substring(index + 1)); - } - autoResetEvent.Set(); // Actual file opening is done in a different thread. - } catch (ThreadAbortException) { - break; - } catch { } - } - TerminateClient(); - } - } finally { - if (qtAppWrapperProcess != null) - qtAppWrapperProcess.Dispose(); - TerminateClient(); - } - } - - private void TerminateClient() - { - try { - if (client != null) { - var tmp = client; - client = null; - - if (tmp.Connected) { - var stream = tmp.GetStream(); - stream.Close(); - tmp.Close(); - } - } - } catch { /* ignore */ } - } - } -} diff --git a/src/qtvstools/DefaultEditorsHandler.cs b/src/qtvstools/DefaultEditorsHandler.cs deleted file mode 100644 index d097cc91..00000000 --- a/src/qtvstools/DefaultEditorsHandler.cs +++ /dev/null @@ -1,320 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -using QtProjectLib; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using System.Threading; -using System.Windows.Forms; -using Microsoft.VisualStudio.VCProjectEngine; - -namespace QtVsTools -{ - class DefaultEditorsHandler - { - public static DefaultEditorsHandler Instance - { - get; private set; - } - - public static void Initialize(EnvDTE.DTE dte) - { - Instance = new DefaultEditorsHandler(dte); - } - - public void StartEditor(string fileName) - { - if (string.IsNullOrEmpty(fileName)) - return; - - bool abortOperation; - CheckoutFileIfNeeded(fileName, out abortOperation); - if (abortOperation) - return; - - switch (Path.GetExtension(fileName).ToUpperInvariant()) { - case ".TS": - StartLinguist(fileName); - break; - case ".UI": - StartDesigner(fileName); - Thread.Sleep(1000); // Designer can't cope with many files in a short time. - break; - } - } - - public void StartEditor(DefaultEditor.Kind type) - { - switch (type) { - case DefaultEditor.Kind.Ts: - StartLinguist(string.Empty); - break; - case DefaultEditor.Kind.Ui: - StartDesigner(string.Empty); - break; - } - } - - private struct Server - { - public int Port { get; set; } - public Process Process { get; set; } - } - - private static class NativeMethods - { - [ResourceExposure(ResourceScope.None)] - [DllImport("user32.dll", SetLastError = true)] - internal static extern void SwitchToThisWindow(IntPtr hWnd, - [MarshalAs(UnmanagedType.Bool)] bool fAltTab); - } - - private readonly EnvDTE.DTE dte; - private static int port; - private static ManualResetEvent portFound = new ManualResetEvent(false); - private static Dictionary<string, Server> servers = new Dictionary<string, Server>(); - - private DefaultEditorsHandler(EnvDTE.DTE dte) - { - this.dte = dte; - } - - private void CheckoutFileIfNeeded(string fileName, out bool abortOperation) - { - abortOperation = false; - - if (QtVSIPSettings.GetDisableCheckoutFiles()) - return; - - var sourceControl = dte.SourceControl; - if (sourceControl == null) - return; - - if (!sourceControl.IsItemUnderSCC(fileName)) - return; - - if (sourceControl.IsItemCheckedOut(fileName)) - return; - - if (QtVSIPSettings.GetAskBeforeCheckoutFile()) { - var shortFileName = Path.GetFileName(fileName); - var dr = MessageBox.Show(SR.GetString("QuestionSCCCheckoutOnOpen", shortFileName), - SR.GetString("Resources_QtVsTools"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, - MessageBoxDefaultButton.Button1); - if (dr == DialogResult.Cancel) - abortOperation = true; - if (dr != DialogResult.Yes) - return; - } - - sourceControl.CheckOutItem(fileName); - } - - private void StartLinguist(string fileName) - { - var qtDir = string.Empty; - if (!GetQtProjectAndDirectory("linguist.exe", out qtDir)) - return; - - try { - var workingDir = string.Empty; - if (!string.IsNullOrEmpty(fileName)) { - workingDir = Path.GetDirectoryName(fileName); - fileName = fileName.Quoute(); - } - GetEditorProcess("linguist.exe", fileName, workingDir, qtDir).Start(); - } catch { - System.Windows.MessageBox.Show(SR.GetString("QtAppNotFoundErrorMessage", - "Qt Linguist"), SR.GetString("QtAppNotFoundErrorTitle", "Linguist")); - } - } - - private void StartDesigner(string fileName) - { - var qtDir = string.Empty; - if (!GetQtProjectAndDirectory("designer.exe", out qtDir)) - return; - - try { - if (!servers.ContainsKey(qtDir) || servers[qtDir].Process.HasExited) { - var arguments = "-server"; - var workingDir = string.Empty; - if (!string.IsNullOrEmpty(fileName)) { - arguments += " " + fileName.Quoute(); - workingDir = Path.GetDirectoryName(fileName); - } - var process = GetEditorProcess("designer.exe", arguments, workingDir, qtDir); - process.StartInfo.UseShellExecute = false; - process.StartInfo.RedirectStandardOutput = true; - process.OutputDataReceived += DesignerOutputHandler; - - process.Start(); - process.BeginOutputReadLine(); - - try { - portFound.WaitOne(5000, false); - } catch (Exception e) { - MessageBox.Show(e.Message); - } - - process.WaitForInputIdle(); - servers[qtDir] = new Server - { - Port = port, - Process = process - }; - portFound.Reset(); - } else { - try { - using (var client = new TcpClient("127.0.0.1", servers[qtDir].Port)) { - var encoder = new System.Text.UTF8Encoding(); - var buffer = encoder.GetBytes(fileName + "\n"); - - var stream = client.GetStream(); - stream.Write(buffer, 0, buffer.Length); - stream.Close(); - } - } catch { - Messages.DisplayErrorMessage(SR.GetString("DesignerAddError")); - } - } - } catch { - MessageBox.Show(SR.GetString("QtAppNotFoundErrorMessage", "Qt Designer"), - SR.GetString("QtAppNotFoundErrorTitle", "Designer")); - return; - } - - try { - if (servers[qtDir].Process.MainWindowHandle == IntPtr.Zero) { - var process = Process.GetProcessById(servers[qtDir].Process.Id); - if (process.MainWindowHandle != IntPtr.Zero) { - servers[qtDir] = new Server - { - Process = process, - Port = servers[qtDir].Port - }; - } - } - NativeMethods.SwitchToThisWindow(servers[qtDir].Process.MainWindowHandle, true); - } catch { - // silent - } - } - - private void DesignerOutputHandler(object sender, DataReceivedEventArgs args) - { - var process = sender as Process; - process.CancelOutputRead(); - process.OutputDataReceived -= DesignerOutputHandler; - - try { - port = Convert.ToInt32(args.Data); - portFound.Set(); // might throw object exposed exception - } catch { } - } - - private bool GetQtProjectAndDirectory(string tool, out string qtDir) - { - var qtVersion = "$(DefaultQtVersion)"; - var project = HelperFunctions.GetSelectedQtProject(dte); - if (project == null) { - project = HelperFunctions.GetSelectedProject(dte); - if (project != null && HelperFunctions.IsQMakeProject(project)) { - var qmakeQtDir = HelperFunctions.GetQtDirFromQMakeProject(project); - qtVersion = QtVersionManager.The().GetQtVersionFromInstallDir(qmakeQtDir); - } - } else { - qtVersion = QtVersionManager.The().GetProjectQtVersion(project); - } - - qtDir = HelperFunctions.FindQtDirWithTools(tool, qtVersion); - - if (string.IsNullOrEmpty(qtDir)) { - var vcProject = project.Object as VCProject; - qtDir = vcProject?.ActiveConfiguration.GetEvaluatedPropertyValue("QtInstallDir"); - } - if (string.IsNullOrEmpty(qtDir)) - MessageBox.Show(SR.GetString("NoDefaultQtVersionError"), SR.GetString("Resources_QtVsTools")); - return !string.IsNullOrEmpty(qtDir); - } - - private Process GetEditorProcess(string editor, string args, string workingDir, string qtDir) - { - var fileName = string.Empty; - if (!string.IsNullOrEmpty(qtDir)) - fileName = Path.Combine(qtDir, "bin", editor); - - // Try to find application in project's Qt directory first - if (!File.Exists(fileName)) { - var project = HelperFunctions.GetSelectedQtProject(dte); - if (project != null) { - var path = QtVersionManager.The().GetInstallPath(project); - if (string.IsNullOrEmpty(path)) - fileName = Path.Combine(path, "bin", editor); - } - } - - // Try with Path - if (!File.Exists(fileName)) - fileName = HelperFunctions.FindFileInPATH(editor); - - // try default Qt version - if (!File.Exists(fileName)) { - var vm = QtVersionManager.The(); - qtDir = vm.GetInstallPath(vm.GetDefaultVersion()); - workingDir = Path.Combine(qtDir, "bin"); - fileName = Path.Combine(workingDir, editor); - } - - if (!File.Exists(fileName)) - return null; - - Process process = null; - try { - process = new Process(); - process.StartInfo = new ProcessStartInfo - { - Arguments = args, - FileName = fileName, - WorkingDirectory = workingDir, - WindowStyle = ProcessWindowStyle.Normal - }; - } catch { - if (process != null) - process.Dispose(); - process = null; - } - return process; - } - } -} diff --git a/src/qtvstools/Qt4DefaultEditors.cs b/src/qtvstools/Qt4DefaultEditors.cs deleted file mode 100644 index 7592a499..00000000 --- a/src/qtvstools/Qt4DefaultEditors.cs +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -namespace QtVsTools -{ - public class Qt4DefaultEditors : DefaultEditorsBase - { - public Qt4DefaultEditors() - : base(uid: @"{6A7385B4-1D62-46e0-A4E3-AED4475371F0}", - wrapper: @"qtappwrapper.exe", editor: @"qrceditor.exe") - { - } - } -} diff --git a/src/qtvstools/Qt5DefaultEditors.cs b/src/qtvstools/Qt5DefaultEditors.cs deleted file mode 100644 index 285fc7af..00000000 --- a/src/qtvstools/Qt5DefaultEditors.cs +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -namespace QtVsTools -{ - public class Qt5DefaultEditors : DefaultEditorsBase - { - public Qt5DefaultEditors() - : base(uid: @"{C80C78C8-F64B-43df-9A53-96F7C44A1EB6}", - wrapper: @"qt5appwrapper.exe", editor: @"q5rceditor.exe") - { - } - } -} diff --git a/src/qtvstools/QtVsTools.csproj b/src/qtvstools/QtVsTools.csproj index 886f30a7..31198be1 100644 --- a/src/qtvstools/QtVsTools.csproj +++ b/src/qtvstools/QtVsTools.csproj @@ -66,10 +66,6 @@ <Compile Include="Common\Json\Serializable.cs" /> <Compile Include="Common\Json\SerializableEnum.cs" /> <Compile Include="Common\Json\Serializer.cs" /> - <Compile Include="DefaultEditor.cs" /> - <Compile Include="DefaultEditorsBase.cs" /> - <Compile Include="DefaultEditorsClient.cs" /> - <Compile Include="DefaultEditorsHandler.cs" /> <Compile Include="DteEventsHandler.cs" /> <Compile Include="Editors\Editor.cs" /> <Compile Include="Editors\Editor.QtDesigner.cs" /> @@ -150,8 +146,6 @@ <Compile Include="QML\Parser\QmlParserInterop.cs" /> <Compile Include="QML\Syntax\QmlAst.cs" /> <Compile Include="QML\Syntax\QmlSyntax.cs" /> - <Compile Include="Qt4DefaultEditors.cs" /> - <Compile Include="Qt5DefaultEditors.cs" /> <Compile Include="QtHelpLinkChooser.xaml.cs"> <DependentUpon>QtHelpLinkChooser.xaml</DependentUpon> </Compile> @@ -164,7 +158,6 @@ <Compile Include="QtMsBuild\Components\QtProjectTracker.cs" /> <Compile Include="QtProjectContextMenu.cs" /> <Compile Include="QtSolutionContextMenu.cs" /> - <Compile Include="QtVsToolsDefaultEditors.cs" /> <Compile Include="SR.cs" /> <Compile Include="Translation.cs" /> <Compile Include="TranslationItem.cs" /> @@ -382,13 +375,6 @@ <Project>{4cee73c9-fcfa-3a72-a0a3-036bdbb3240f}</Project> <Name>qrceditor</Name> </ProjectReference> - <ProjectReference Include="..\qtappwrapper\QtAppWrapper.csproj"> - <Project>{6E591BB2-3C81-4AB5-B3B0-096045754C3A}</Project> - <Name>QtAppWrapper</Name> - <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX> - <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\qtprojectlib\QtProjectLib.csproj"> <Project>{faa69518-2feb-4954-9d2c-e7bd6121ea9c}</Project> <Name>QtProjectLib</Name> diff --git a/src/qtvstools/QtVsToolsDefaultEditors.cs b/src/qtvstools/QtVsToolsDefaultEditors.cs deleted file mode 100644 index c6c9b970..00000000 --- a/src/qtvstools/QtVsToolsDefaultEditors.cs +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt VS Tools. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -namespace QtVsTools -{ - public class QtVsToolsDefaultEditors : DefaultEditorsBase - { - public QtVsToolsDefaultEditors() // Set VSIX specific values - : base(uid: @"{15021976-2F08-4C44-BFF4-73CCDCB50473}", - wrapper: @"QtAppWrapper.exe", editor: @"QrcEditor.exe") - { - } - } -} diff --git a/src/qtvstools/Resources.resx b/src/qtvstools/Resources.resx index b0c24a77..43494cd2 100644 --- a/src/qtvstools/Resources.resx +++ b/src/qtvstools/Resources.resx @@ -238,9 +238,6 @@ Converting project {0}/{1}: {2}...</value> <data name="CoreLibrary" xml:space="preserve"> <value>Core</value> </data> - <data name="CouldNotConnectToAppwrapper" xml:space="preserve"> - <value>Cannot connect to Appwrapper. Please make sure that TCP port {0} is not blocked.</value> - </data> <data name="DeclarativeLibrary" xml:space="preserve"> <value>Declarative</value> </data> diff --git a/src/qtvstools/Vsix.cs b/src/qtvstools/Vsix.cs index d5e207fa..7561e4b2 100644 --- a/src/qtvstools/Vsix.cs +++ b/src/qtvstools/Vsix.cs @@ -133,17 +133,6 @@ namespace QtVsTools } } - private string appWrapperPath; - public string AppWrapperPath - { - get - { - if (appWrapperPath == null) - appWrapperPath = locateHelperExecutable("QtAppWrapper.exe"); - return appWrapperPath; - } - } - private string qmakeFileReaderPath; public string QMakeFileReaderPath { |