first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Codice.Client.Common;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class AuthToken
|
||||
{
|
||||
internal static string GetForServer(string server)
|
||||
{
|
||||
ServerProfile serverProfile = CmConnection.Get().
|
||||
GetProfileManager().GetProfileForServer(server);
|
||||
|
||||
string authToken = serverProfile != null ?
|
||||
CmConnection.Get().
|
||||
BuildWebApiTokenForCloudEditionForUser(
|
||||
serverProfile.Server,
|
||||
serverProfile.GetSEIDWorkingMode(),
|
||||
serverProfile.SecurityConfig):
|
||||
CmConnection.Get().
|
||||
BuildWebApiTokenForCloudEditionForUser(
|
||||
server,
|
||||
ClientConfig.Get().GetSEIDWorkingMode(),
|
||||
ClientConfig.Get().GetSecurityConfig());
|
||||
|
||||
if (string.IsNullOrEmpty(authToken))
|
||||
{
|
||||
authToken = CmConnection.Get().
|
||||
BuildWebApiTokenForCloudEditionDefaultUser();
|
||||
}
|
||||
|
||||
return authToken;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537d6b35c9cc8bd42a656dfc8cb64948
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class BringWindowToFront
|
||||
{
|
||||
internal static void ForWindowsProcess(int processId)
|
||||
{
|
||||
IntPtr handle = FindMainWindowForProcess(processId);
|
||||
|
||||
if (IsIconic(handle))
|
||||
ShowWindow(handle, SW_RESTORE);
|
||||
|
||||
SetForegroundWindow(handle);
|
||||
}
|
||||
|
||||
static IntPtr FindMainWindowForProcess(int processId)
|
||||
{
|
||||
IntPtr result = IntPtr.Zero;
|
||||
|
||||
EnumWindows(delegate (IntPtr wnd, IntPtr param)
|
||||
{
|
||||
uint windowProcessId = 0;
|
||||
GetWindowThreadProcessId(wnd, out windowProcessId);
|
||||
|
||||
if (windowProcessId == processId &&
|
||||
IsMainWindow(wnd))
|
||||
{
|
||||
result = wnd;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool IsMainWindow(IntPtr handle)
|
||||
{
|
||||
return GetWindow(new HandleRef(null, handle), GW_OWNER) == IntPtr.Zero
|
||||
&& IsWindowVisible(new HandleRef(null, handle));
|
||||
}
|
||||
|
||||
// Delegate to filter which windows to include
|
||||
delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
static extern IntPtr GetWindow(HandleRef hWnd, int uCmd);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
static extern bool IsWindowVisible(HandleRef hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool SetForegroundWindow(IntPtr handle);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool IsIconic(IntPtr handle);
|
||||
|
||||
const int GW_OWNER = 4;
|
||||
const int SW_RESTORE = 9;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc5c1fa3d4519114cb21f3fedfe6039d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class FindTool
|
||||
{
|
||||
internal static string ObtainToolCommand(
|
||||
string toolName, List<string> installationPaths)
|
||||
{
|
||||
List<string> processPaths = GetPathsFromEnvVariable(
|
||||
PATH_ENVIRONMENT_VARIABLE,
|
||||
EnvironmentVariableTarget.Process);
|
||||
|
||||
List<string> machinePaths = GetPathsFromEnvVariable(
|
||||
PATH_ENVIRONMENT_VARIABLE,
|
||||
EnvironmentVariableTarget.Machine);
|
||||
|
||||
List<string> pathsToLookup = new List<string>();
|
||||
pathsToLookup.AddRange(processPaths);
|
||||
pathsToLookup.AddRange(machinePaths);
|
||||
pathsToLookup.AddRange(installationPaths);
|
||||
|
||||
string toolPath = FindToolInPaths(toolName, pathsToLookup);
|
||||
|
||||
if (string.IsNullOrEmpty(toolPath))
|
||||
return null;
|
||||
|
||||
EnsureIsInProcessPathEnvVariable(toolPath, processPaths);
|
||||
|
||||
return toolPath;
|
||||
}
|
||||
|
||||
static string FindToolInPaths(
|
||||
string toolName,
|
||||
List<string> paths)
|
||||
{
|
||||
foreach (string path in paths)
|
||||
{
|
||||
if (path == null)
|
||||
continue;
|
||||
|
||||
if (path.Trim() == string.Empty)
|
||||
continue;
|
||||
|
||||
string filePath = CleanFolderPath(path);
|
||||
|
||||
filePath = Path.Combine(filePath, toolName);
|
||||
|
||||
if (File.Exists(filePath))
|
||||
return Path.GetFullPath(filePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static string CleanFolderPath(string folderPath)
|
||||
{
|
||||
foreach (char c in Path.GetInvalidPathChars())
|
||||
folderPath = folderPath.Replace(c.ToString(), string.Empty);
|
||||
|
||||
return folderPath;
|
||||
}
|
||||
|
||||
static List<string> GetPathsFromEnvVariable(
|
||||
string variableName,
|
||||
EnvironmentVariableTarget target)
|
||||
{
|
||||
string value = Environment.GetEnvironmentVariable(variableName, target);
|
||||
return new List<string>(value.Split(Path.PathSeparator));
|
||||
}
|
||||
|
||||
static void EnsureIsInProcessPathEnvVariable(
|
||||
string toolPath,
|
||||
List<string> processPaths)
|
||||
{
|
||||
string plasticInstallDir = Path.GetDirectoryName(toolPath);
|
||||
|
||||
if (processPaths.Contains(plasticInstallDir, StringComparer.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
Environment.SetEnvironmentVariable(
|
||||
PATH_ENVIRONMENT_VARIABLE,
|
||||
string.Concat(plasticInstallDir, Path.PathSeparator, processPaths),
|
||||
EnvironmentVariableTarget.Process);
|
||||
}
|
||||
|
||||
const string PATH_ENVIRONMENT_VARIABLE = "PATH";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e0d1d689c88f76448cad390443d7ba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.LogWrapper;
|
||||
using Codice.Utils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class IsExeAvailable
|
||||
{
|
||||
internal static bool ForMode(bool isGluonMode)
|
||||
{
|
||||
string toolPath = isGluonMode ?
|
||||
PlasticInstallPath.GetGluonExePath() :
|
||||
PlasticInstallPath.GetPlasticExePath();
|
||||
|
||||
return !string.IsNullOrEmpty(toolPath);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class PlasticInstallPath
|
||||
{
|
||||
internal static string GetClientBinDir()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
{
|
||||
string plasticExePath = GetPlasticExePath();
|
||||
|
||||
if (plasticExePath == null)
|
||||
return null;
|
||||
|
||||
return Path.GetDirectoryName(plasticExePath);
|
||||
}
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
string path = GetToolCommand(Plastic.NEW_GUI_MACOS);
|
||||
if (path != null)
|
||||
return GetExistingDir(ToolConstants.NEW_MACOS_BINDIR);
|
||||
|
||||
return GetExistingDir(ToolConstants.LEGACY_MACOS_BINDIR);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static string GetPlasticExePath()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return FindTool.ObtainToolCommand(
|
||||
Plastic.GUI_WINDOWS,
|
||||
new List<String>() { GetWindowsInstallationFolder() });
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
string path = GetToolCommand(Plastic.NEW_GUI_MACOS);
|
||||
if(path != null)
|
||||
return path;
|
||||
|
||||
return GetToolCommand(Plastic.LEGACY_GUI_MACOS);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static string GetGluonExePath()
|
||||
{
|
||||
if (PlatformIdentifier.IsWindows())
|
||||
return FindTool.ObtainToolCommand(
|
||||
Gluon.GUI_WINDOWS,
|
||||
new List<String>() { GetWindowsInstallationFolder() });
|
||||
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
string path = GetToolCommand(Gluon.NEW_GUI_MACOS);
|
||||
if (path != null)
|
||||
return path;
|
||||
|
||||
return GetToolCommand(Gluon.LEGACY_GUI_MACOS);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static void LogInstallationInfo()
|
||||
{
|
||||
string plasticClientBinDir = GetClientBinDir();
|
||||
|
||||
if (string.IsNullOrEmpty(plasticClientBinDir))
|
||||
{
|
||||
mLog.DebugFormat("No installation found, behaving as {0} Edition",
|
||||
EditionToken.IsCloudEdition() ? "Cloud" : "Enterprise");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isCloudPlasticInstall = File.Exists(Path.Combine(plasticClientBinDir, EditionToken.CLOUD_EDITION_FILE_NAME));
|
||||
|
||||
mLog.DebugFormat("{0} Edition detected - installation directory: {1}",
|
||||
isCloudPlasticInstall ? "Cloud" : "Enterprise",
|
||||
plasticClientBinDir);
|
||||
mLog.DebugFormat("Local token: {0} Edition",
|
||||
EditionToken.IsCloudEdition() ? "Cloud" : "Enterprise");
|
||||
}
|
||||
}
|
||||
|
||||
static string GetToolCommand(string tool)
|
||||
{
|
||||
return File.Exists(tool) ? tool : null;
|
||||
}
|
||||
|
||||
static string GetExistingDir(string directory)
|
||||
{
|
||||
return Directory.Exists(directory) ? directory : null;
|
||||
}
|
||||
|
||||
static string GetWindowsInstallationFolder()
|
||||
{
|
||||
string programFilesFolder = Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.ProgramFiles);
|
||||
|
||||
return Path.Combine(Path.Combine(programFilesFolder,
|
||||
PLASTICSCM_FOLDER), PLASTICSCM_SUBFOLDER);
|
||||
}
|
||||
|
||||
const string PLASTICSCM_FOLDER = "PlasticSCM5";
|
||||
const string PLASTICSCM_SUBFOLDER = "client";
|
||||
|
||||
static readonly ILog mLog = PlasticApp.GetLogger("PlasticInstallPath");
|
||||
|
||||
class Plastic
|
||||
{
|
||||
internal const string GUI_WINDOWS = "plastic.exe";
|
||||
internal const string LEGACY_GUI_MACOS = "/Applications/PlasticSCM.app/Contents/MacOS/PlasticSCM";
|
||||
internal const string NEW_GUI_MACOS = "/Applications/PlasticSCM.app/Contents/MacOS/macplasticx";
|
||||
}
|
||||
|
||||
class Gluon
|
||||
{
|
||||
internal const string GUI_WINDOWS = "gluon.exe";
|
||||
internal const string LEGACY_GUI_MACOS = "/Applications/Gluon.app/Contents/MacOS/Gluon";
|
||||
internal const string NEW_GUI_MACOS = "/Applications/Gluon.app/Contents/MacOS/macgluonx";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f25df29da91c45449ada5f3da8cf20ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,23 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
using Codice.Utils;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class LaunchInstaller
|
||||
{
|
||||
internal static Process ForPlatform(string installerPath)
|
||||
{
|
||||
if (PlatformIdentifier.IsMac())
|
||||
{
|
||||
return Process.Start(
|
||||
ToolConstants.Installer.INSTALLER_MACOS_OPEN,
|
||||
string.Format(ToolConstants.Installer.INSTALLER_MACOS_OPEN_ARGS, installerPath));
|
||||
}
|
||||
|
||||
return Process.Start(
|
||||
installerPath,
|
||||
ToolConstants.Installer.INSTALLER_WINDOWS_ARGS);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b405b01c6be83742bc000fb416b4dbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6d05b29e607e62478df26227566e1b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,53 @@
|
||||
namespace Unity.PlasticSCM.Editor.Tool
|
||||
{
|
||||
internal static class ToolConstants
|
||||
{
|
||||
internal static class Plastic
|
||||
{
|
||||
|
||||
internal const string GUI_CONFIGURE_ARG = "--configure";
|
||||
|
||||
internal const string GUI_WINDOWS_WK_ARG = "--wk=\"{0}\"";
|
||||
internal const string GUI_WINDOWS_BREX_ARG = "--branchexplorer=\"{0}\"";
|
||||
internal const string GUI_WINDOWS_MERGE_ARG = "--resolve=\"{0}\"";
|
||||
internal const string GUI_WINDOWS_INCOMING_CHANGES_ARG = "--resolve=\"{0}\" --incomingmerge";
|
||||
|
||||
internal const string GUI_MACOS_WK_EXPLORER_ARG = "--wk=\"{0}\" --view=ItemsView";
|
||||
internal const string GUI_MACOS_BREX_ARG = "--wk=\"{0}\" --view=BranchExplorerView";
|
||||
internal const string GUI_MACOS_MERGE_ARG = "--wk=\"{0}\" --view=MergeView";
|
||||
internal const string GUI_MACOS_INCOMING_CHANGES_ARG = "--wk=\"{0}\" --view=IncomingChangesView";
|
||||
internal const string GUI_MACOS_COMMAND_FILE_ARG = " --command-file=\"{0}\"";
|
||||
internal const string GUI_MACOS_COMMAND_FILE = "macplastic-command-file.txt";
|
||||
|
||||
internal const string GUI_CHANGESET_DIFF_ARG = "--diffchangeset=\"{0}\"";
|
||||
internal const string GUI_SELECTED_CHANGESETS_DIFF_ARGS = "--diffchangesetsrc=\"{0}\" --diffchangesetdst=\"{1}\"";
|
||||
internal const string GUI_BRANCH_DIFF_ARG = "--diffbranch=\"{0}\"";
|
||||
}
|
||||
|
||||
internal static class Gluon
|
||||
{
|
||||
|
||||
internal const string GUI_CONFIGURE_ARG = "--configure";
|
||||
|
||||
internal const string GUI_WK_EXPLORER_ARG = "--wk=\"{0}\" --view=WorkspaceExplorerView";
|
||||
internal const string GUI_WK_CONFIGURATION_ARG = "--wk=\"{0}\" --view=WorkspaceConfigurationView";
|
||||
internal const string GUI_WK_INCOMING_CHANGES_ARG = "--wk=\"{0}\" --view=IncomingChangesView";
|
||||
internal const string GUI_COMMAND_FILE_ARG = " --command-file=\"{0}\"";
|
||||
internal const string GUI_COMMAND_FILE = "gluon-command-file.txt";
|
||||
|
||||
internal const string GUI_CHANGESET_DIFF_ARG = "--diffchangeset=\"{0}\"";
|
||||
internal const string GUI_SELECTED_CHANGESETS_DIFF_ARGS = "--diffchangesetsrc=\"{0}\" --diffchangesetdst=\"{1}\"";
|
||||
internal const string GUI_BRANCH_DIFF_ARG = "--diffbranch=\"{0}\"";
|
||||
}
|
||||
|
||||
internal static class Installer
|
||||
{
|
||||
internal const string INSTALLER_WINDOWS_ARGS = "--mode unattended --unattendedmodeui minimal";
|
||||
internal const string INSTALLER_MACOS_OPEN = "open";
|
||||
internal const string INSTALLER_MACOS_OPEN_ARGS = "-W -n {0}";
|
||||
}
|
||||
|
||||
internal const string LEGACY_MACOS_BINDIR = "/Applications/PlasticSCM.app/Contents/MonoBundle";
|
||||
internal const string NEW_MACOS_BINDIR = "/Applications/PlasticSCM.app/Contents/MacOS";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de6e8913aefd69d4ca90a7216d225d3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user