Ejemplo n.º 1
0
        /// <summary>
        /// Uninstalls the target application on the target device.
        /// </summary>
        /// <param name="packageFamilyName"></param>
        /// <param name="targetDevice"></param>
        /// <param name="showDialog"></param>
        /// <returns>True, if uninstall was a success.</returns>
        public static bool UninstallApp(string packageFamilyName, ConnectInfo targetDevice, bool showDialog = true)
        {
            AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice);

            if (appDetails == null)
            {
                Debug.Log(string.Format("Application '{0}' not found", packageFamilyName));
                return(false);
            }

            string query = string.Format("{0}?package={1}",
                                         string.Format(API_InstallQuery, FinalizeUrl(targetDevice.IP)),
                                         WWW.EscapeURL(appDetails.PackageFullName));

            bool        success       = WebRequestDelete(query, GetBasicAuthHeader(targetDevice), showDialog);
            MachineName targetMachine = GetMachineName(targetDevice);

            if (success)
            {
                Debug.LogFormat("Successfully uninstalled {0} on {1}.", packageFamilyName, targetMachine.ComputerName);
            }
            else
            {
                Debug.LogErrorFormat("Failed to uninstall {0} on {1}", packageFamilyName, targetMachine.ComputerName);
            }

            return(success);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Kills the target application on the target device.
        /// </summary>
        /// <param name="packageFamilyName"></param>
        /// <param name="targetDevice"></param>
        /// <param name="showDialog"></param>
        /// <returns>true, if application was successfully stopped.</returns>
        public static bool KillApp(string packageFamilyName, ConnectInfo targetDevice, bool showDialog = true)
        {
            AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice);

            if (appDetails == null)
            {
                Debug.LogError("Application not found");
                return(false);
            }

            string query = string.Format("{0}?package={1}",
                                         string.Format(API_AppQuery, FinalizeUrl(targetDevice.IP)),
#pragma warning disable CS0618 // deprecated
                                         WWW.EscapeURL(EncodeTo64(appDetails.PackageFullName)));

#pragma warning restore CS0618 // deprecated

            bool        success       = WebRequestDelete(query, GetBasicAuthHeader(targetDevice), showDialog);
            MachineName targetMachine = GetMachineName(targetDevice);

            if (success)
            {
                Debug.LogFormat("Successfully stopped {0} on {1}.", packageFamilyName, targetMachine.ComputerName);
            }

            return(success);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the <see cref="MachineName"/> of the target device.
        /// </summary>
        /// <param name="targetDevice"></param>
        /// <returns><see cref="MachineName"/></returns>
        public static MachineName GetMachineName(ConnectInfo targetDevice)
        {
            MachineName machineName = null;
            string      query       = string.Format(API_GetMachineNameQuery, FinalizeUrl(targetDevice.IP));
            string      response    = WebRequestGet(query, GetBasicAuthHeader(targetDevice, true), false);

            if (!string.IsNullOrEmpty(response))
            {
                machineName = JsonUtility.FromJson <MachineName>(response);
            }

            return(machineName);
        }