Loading WindowsDevicePortalWrapper/MockDataGenerator/Program.cs +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ namespace MockDataGenerator new Endpoint(HttpMethods.Get, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.SystemPerfApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.Get, DevicePortal.XboxLiveSandboxApi), }; /// <summary> Loading WindowsDevicePortalWrapper/TestAppXbox/Operations/SettingOperation.cs→WindowsDevicePortalWrapper/TestAppXbox/Operations/ConfigOperation.cs +6 −6 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="SettingOperation.cs" company="Microsoft Corporation"> // <copyright file="ConfigOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- Loading @@ -12,14 +12,14 @@ using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; namespace XboxWdpDriver { /// <summary> /// Helper for Setting related operations /// Helper for Config related operations /// </summary> public class SettingOperation public class ConfigOperation { /// <summary> /// Usage message for this operation /// </summary> private const string XblSettingUsageMessage = "Usage:\n" + private const string ConfigUsageMessage = "Usage:\n" + " [/setting:<setting name> [/value:<setting value>]]\n" + " Gets current settings and their values. If\n" + " /setting is specified, only returns that value.\n" + Loading @@ -28,7 +28,7 @@ namespace XboxWdpDriver " value.\n"; /// <summary> /// Main entry point for handling a Setting operation /// Main entry point for handling a Config operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> Loading @@ -36,7 +36,7 @@ namespace XboxWdpDriver { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(XblSettingUsageMessage); Console.WriteLine(ConfigUsageMessage); return; } Loading WindowsDevicePortalWrapper/TestAppXbox/Operations/FiddlerOperation.cs 0 → 100644 +114 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="FiddlerOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal; namespace XboxWdpDriver { /// <summary> /// Helper for Fiddler related operations /// </summary> public class FiddlerOperation { /// <summary> /// Usage message for this operation /// </summary> private const string FiddlerUsageMessage = "Usage:\n" + " /state:<on or off> [/reboot] [/proxyaddress:<proxy address> /proxyport:<proxy port> /certpath:<path to cert file>]\n" + " Whether to enable or disable Fiddler. Enabling and disabling Fiddler\n" + " requires a reboot. You can specify the /reboot flag to do the reboot\n" + " automatically. If Fiddler is being enabled, proxyaddress and proxyport\n" + " are both required. If Fiddler has not been configured on this console\n" + " previously, then the cert file is also required."; /// <summary> /// Main entry point for handling a Fiddler operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(FiddlerUsageMessage); return; } string state = parameters.GetParameterValue("state"); if (string.IsNullOrEmpty(state)) { Console.WriteLine("/state parameter is required."); Console.WriteLine(); Console.WriteLine(FiddlerUsageMessage); return; } try { if (string.Equals(state, "on", StringComparison.OrdinalIgnoreCase)) { string proxyAddress = parameters.GetParameterValue("proxyaddress"); string proxyPort = parameters.GetParameterValue("proxyport"); if (string.IsNullOrEmpty(proxyAddress) || string.IsNullOrEmpty(proxyPort)) { Console.WriteLine("/proxyaddress and /proxyport are required for enabling Fiddler."); Console.WriteLine(); Console.WriteLine(FiddlerUsageMessage); return; } Task fiddlerEnableTask = portal.EnableFiddlerTracing(proxyAddress, proxyPort, parameters.GetParameterValue("certpath")); fiddlerEnableTask.Wait(); Console.WriteLine("Fiddler enabled."); } else if (string.Equals(state, "off", StringComparison.OrdinalIgnoreCase)) { Task fiddlerDisableTask = portal.DisableFiddlerTracing(); fiddlerDisableTask.Wait(); Console.WriteLine("Fiddler disabled."); } else { Console.WriteLine("Unknown state parameter: {0}. Must be 'on' or 'off'.", state); Console.WriteLine(); Console.WriteLine(FiddlerUsageMessage); return; } if (parameters.HasFlag("reboot")) { Task rebootTask = portal.Reboot(); rebootTask.Wait(); Console.WriteLine("Console rebooting..."); } else { Console.WriteLine("A reboot is required before this takes effect."); } } catch (AggregateException e) { if (e.InnerException is DevicePortalException) { DevicePortalException innerException = e.InnerException as DevicePortalException; Console.WriteLine(string.Format("Exception encountered: {0}, hr = 0x{1:X} : {2}", innerException.StatusCode, innerException.HResult, innerException.Reason)); } else { Console.WriteLine(string.Format("Unexpected exception encountered: {0}", e.Message)); } return; } } } } No newline at end of file WindowsDevicePortalWrapper/TestAppXbox/Operations/ListProcessesOperation.cs 0 → 100644 +69 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="ListProcessesOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal; using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; using System.Threading; namespace XboxWdpDriver { /// <summary> /// Helper for Listing processes /// </summary> public class ListProcessesOperation { /// <summary> /// Main entry point for handling listing processes /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { RunningProcesses runningProcesses = null; if (parameters.HasFlag(ParameterHelper.Listen)) { ManualResetEvent runningProcessesReceived = new ManualResetEvent(false); WebSocketMessageReceivedEventHandler<RunningProcesses> runningProcessesReceivedHandler = delegate (DevicePortal sender, WebSocketMessageReceivedEventArgs<RunningProcesses> runningProccesesArgs) { if (runningProccesesArgs.Message != null) { runningProcesses = runningProccesesArgs.Message; runningProcessesReceived.Set(); } }; portal.RunningProcessesMessageReceived += runningProcessesReceivedHandler; Task startListeningForProcessesTask = portal.StartListeningForRunningProcesses(); startListeningForProcessesTask.Wait(); runningProcessesReceived.WaitOne(); Task stopListeningForProcessesTask = portal.StopListeningForRunningProcesses(); stopListeningForProcessesTask.Wait(); portal.RunningProcessesMessageReceived -= runningProcessesReceivedHandler; } else { Task<DevicePortal.RunningProcesses> getRunningProcessesTask = portal.GetRunningProcesses(); runningProcesses = getRunningProcessesTask.Result; } foreach (DeviceProcessInfo process in runningProcesses.Processes) { if (!string.IsNullOrEmpty(process.Name)) { Console.WriteLine(process.Name); } } } } } No newline at end of file WindowsDevicePortalWrapper/TestAppXbox/Operations/SandboxOperation.cs 0 → 100644 +70 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="SandboxOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal; using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; namespace XboxWdpDriver { /// <summary> /// Helper for Sandbox related operations /// </summary> public class SandboxOperation { /// <summary> /// Usage message for this operation /// </summary> private const string SandboxUsageMessage = "Usage:\n" + " [/value:<desired value> [/reboot]]\n" + " Gets or sets the current Xbox Live sandbox value. Changing the current\n" + " sandbox requires a reboot, which can be done automatically be specifying\n" + " the /reboot flag."; /// <summary> /// Main entry point for handling a Sandbox operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(SandboxUsageMessage); return; } string desiredValue = parameters.GetParameterValue("value"); if (string.IsNullOrEmpty(desiredValue)) { Task<Sandbox> getSandboxTask = portal.GetXboxLiveSandbox(); getSandboxTask.Wait(); Console.WriteLine(getSandboxTask.Result); } else { Task<Sandbox> setSandboxTask = portal.SetXboxLiveSandbox(desiredValue); setSandboxTask.Wait(); Console.WriteLine("{0} -> {1}", setSandboxTask.Result, desiredValue); if (parameters.HasFlag("reboot")) { Task rebootTask = portal.Reboot(); rebootTask.Wait(); Console.WriteLine("Console rebooting..."); } else { Console.WriteLine("A reboot is required before this setting takes effect."); } } } } } No newline at end of file Loading
WindowsDevicePortalWrapper/MockDataGenerator/Program.cs +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ namespace MockDataGenerator new Endpoint(HttpMethods.Get, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.SystemPerfApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.Get, DevicePortal.XboxLiveSandboxApi), }; /// <summary> Loading
WindowsDevicePortalWrapper/TestAppXbox/Operations/SettingOperation.cs→WindowsDevicePortalWrapper/TestAppXbox/Operations/ConfigOperation.cs +6 −6 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="SettingOperation.cs" company="Microsoft Corporation"> // <copyright file="ConfigOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- Loading @@ -12,14 +12,14 @@ using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; namespace XboxWdpDriver { /// <summary> /// Helper for Setting related operations /// Helper for Config related operations /// </summary> public class SettingOperation public class ConfigOperation { /// <summary> /// Usage message for this operation /// </summary> private const string XblSettingUsageMessage = "Usage:\n" + private const string ConfigUsageMessage = "Usage:\n" + " [/setting:<setting name> [/value:<setting value>]]\n" + " Gets current settings and their values. If\n" + " /setting is specified, only returns that value.\n" + Loading @@ -28,7 +28,7 @@ namespace XboxWdpDriver " value.\n"; /// <summary> /// Main entry point for handling a Setting operation /// Main entry point for handling a Config operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> Loading @@ -36,7 +36,7 @@ namespace XboxWdpDriver { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(XblSettingUsageMessage); Console.WriteLine(ConfigUsageMessage); return; } Loading
WindowsDevicePortalWrapper/TestAppXbox/Operations/FiddlerOperation.cs 0 → 100644 +114 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="FiddlerOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal; namespace XboxWdpDriver { /// <summary> /// Helper for Fiddler related operations /// </summary> public class FiddlerOperation { /// <summary> /// Usage message for this operation /// </summary> private const string FiddlerUsageMessage = "Usage:\n" + " /state:<on or off> [/reboot] [/proxyaddress:<proxy address> /proxyport:<proxy port> /certpath:<path to cert file>]\n" + " Whether to enable or disable Fiddler. Enabling and disabling Fiddler\n" + " requires a reboot. You can specify the /reboot flag to do the reboot\n" + " automatically. If Fiddler is being enabled, proxyaddress and proxyport\n" + " are both required. If Fiddler has not been configured on this console\n" + " previously, then the cert file is also required."; /// <summary> /// Main entry point for handling a Fiddler operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(FiddlerUsageMessage); return; } string state = parameters.GetParameterValue("state"); if (string.IsNullOrEmpty(state)) { Console.WriteLine("/state parameter is required."); Console.WriteLine(); Console.WriteLine(FiddlerUsageMessage); return; } try { if (string.Equals(state, "on", StringComparison.OrdinalIgnoreCase)) { string proxyAddress = parameters.GetParameterValue("proxyaddress"); string proxyPort = parameters.GetParameterValue("proxyport"); if (string.IsNullOrEmpty(proxyAddress) || string.IsNullOrEmpty(proxyPort)) { Console.WriteLine("/proxyaddress and /proxyport are required for enabling Fiddler."); Console.WriteLine(); Console.WriteLine(FiddlerUsageMessage); return; } Task fiddlerEnableTask = portal.EnableFiddlerTracing(proxyAddress, proxyPort, parameters.GetParameterValue("certpath")); fiddlerEnableTask.Wait(); Console.WriteLine("Fiddler enabled."); } else if (string.Equals(state, "off", StringComparison.OrdinalIgnoreCase)) { Task fiddlerDisableTask = portal.DisableFiddlerTracing(); fiddlerDisableTask.Wait(); Console.WriteLine("Fiddler disabled."); } else { Console.WriteLine("Unknown state parameter: {0}. Must be 'on' or 'off'.", state); Console.WriteLine(); Console.WriteLine(FiddlerUsageMessage); return; } if (parameters.HasFlag("reboot")) { Task rebootTask = portal.Reboot(); rebootTask.Wait(); Console.WriteLine("Console rebooting..."); } else { Console.WriteLine("A reboot is required before this takes effect."); } } catch (AggregateException e) { if (e.InnerException is DevicePortalException) { DevicePortalException innerException = e.InnerException as DevicePortalException; Console.WriteLine(string.Format("Exception encountered: {0}, hr = 0x{1:X} : {2}", innerException.StatusCode, innerException.HResult, innerException.Reason)); } else { Console.WriteLine(string.Format("Unexpected exception encountered: {0}", e.Message)); } return; } } } } No newline at end of file
WindowsDevicePortalWrapper/TestAppXbox/Operations/ListProcessesOperation.cs 0 → 100644 +69 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="ListProcessesOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal; using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; using System.Threading; namespace XboxWdpDriver { /// <summary> /// Helper for Listing processes /// </summary> public class ListProcessesOperation { /// <summary> /// Main entry point for handling listing processes /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { RunningProcesses runningProcesses = null; if (parameters.HasFlag(ParameterHelper.Listen)) { ManualResetEvent runningProcessesReceived = new ManualResetEvent(false); WebSocketMessageReceivedEventHandler<RunningProcesses> runningProcessesReceivedHandler = delegate (DevicePortal sender, WebSocketMessageReceivedEventArgs<RunningProcesses> runningProccesesArgs) { if (runningProccesesArgs.Message != null) { runningProcesses = runningProccesesArgs.Message; runningProcessesReceived.Set(); } }; portal.RunningProcessesMessageReceived += runningProcessesReceivedHandler; Task startListeningForProcessesTask = portal.StartListeningForRunningProcesses(); startListeningForProcessesTask.Wait(); runningProcessesReceived.WaitOne(); Task stopListeningForProcessesTask = portal.StopListeningForRunningProcesses(); stopListeningForProcessesTask.Wait(); portal.RunningProcessesMessageReceived -= runningProcessesReceivedHandler; } else { Task<DevicePortal.RunningProcesses> getRunningProcessesTask = portal.GetRunningProcesses(); runningProcesses = getRunningProcessesTask.Result; } foreach (DeviceProcessInfo process in runningProcesses.Processes) { if (!string.IsNullOrEmpty(process.Name)) { Console.WriteLine(process.Name); } } } } } No newline at end of file
WindowsDevicePortalWrapper/TestAppXbox/Operations/SandboxOperation.cs 0 → 100644 +70 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="SandboxOperation.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal; using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; namespace XboxWdpDriver { /// <summary> /// Helper for Sandbox related operations /// </summary> public class SandboxOperation { /// <summary> /// Usage message for this operation /// </summary> private const string SandboxUsageMessage = "Usage:\n" + " [/value:<desired value> [/reboot]]\n" + " Gets or sets the current Xbox Live sandbox value. Changing the current\n" + " sandbox requires a reboot, which can be done automatically be specifying\n" + " the /reboot flag."; /// <summary> /// Main entry point for handling a Sandbox operation /// </summary> /// <param name="portal">DevicePortal reference for communicating with the device.</param> /// <param name="parameters">Parsed command line parameters.</param> public static void HandleOperation(DevicePortal portal, ParameterHelper parameters) { if (parameters.HasFlag(ParameterHelper.HelpFlag)) { Console.WriteLine(SandboxUsageMessage); return; } string desiredValue = parameters.GetParameterValue("value"); if (string.IsNullOrEmpty(desiredValue)) { Task<Sandbox> getSandboxTask = portal.GetXboxLiveSandbox(); getSandboxTask.Wait(); Console.WriteLine(getSandboxTask.Result); } else { Task<Sandbox> setSandboxTask = portal.SetXboxLiveSandbox(desiredValue); setSandboxTask.Wait(); Console.WriteLine("{0} -> {1}", setSandboxTask.Result, desiredValue); if (parameters.HasFlag("reboot")) { Task rebootTask = portal.Reboot(); rebootTask.Wait(); Console.WriteLine("Console rebooting..."); } else { Console.WriteLine("A reboot is required before this setting takes effect."); } } } } } No newline at end of file