Ejemplo n.º 1
0
        public static bool Uninstall(Authorization auth)
        {
            string pListFile       = Path.Combine("/Library/LaunchDaemons", HELPER_LABEL + ".plist");
            string privilegeHelper = Path.Combine("/Library/PrivilegedHelperTools", HELPER_LABEL);

            Logging.Info("Uninstalling old helper...");

            if (!MacHelpers.LibUninstallHelperWithAuthorization(HELPER_LABEL, auth.Handle))
            {
                Logging.Info("Cannot remove helper");
                return(false);
            }

            if (!MacHelpers.RemoveFile(auth, pListFile))
            {
                Logging.Info(String.Format("Cannot remove file: {0} ", pListFile));
                return(false);
            }

            if (!MacHelpers.RemoveFile(auth, privilegeHelper))
            {
                Logging.Info(String.Format("Cannot remove file: {0} ", privilegeHelper));
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static bool InstallHelper(Authorization authorization)
        {
            Logging.Info("Installing helper with authorization...");

            bool result = MacHelpers.LibInstallHelperWithAuthorization(HELPER_LABEL, authorization.Handle);

            LogHelperInstallationResult(result);
            return(result);
        }
Ejemplo n.º 3
0
        public static bool InstallHelper()
        {
            Logging.Info("Installing helper...");

            bool result = MacHelpers.LibInstallHelper(HELPER_LABEL);

            LogHelperInstallationResult(result);
            return(result);
        }
Ejemplo n.º 4
0
        private static string GetCurrentVersion()
        {
            var bundlePath =
                System.IO.Path.Combine(
                    NSBundle.MainBundle.BundlePath,
                    "Contents/Library/LaunchServices",
                    HELPER_LABEL);

            return(MacHelpers.GetBundleVersion(bundlePath));
        }
Ejemplo n.º 5
0
        public static bool IsHelperInstalled()
        {
            NSDictionary dict = MacHelpers.SMJobDictionary(HELPER_LABEL);

            if (dict == null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        public static void StartAndConnectToLaunchAgent(Action <int, UInt64> cb)
        {
            // save reference to delegate to avoid processing it by GarbageCollector
            // (we SHOUL NOT pass unnamed action to native code!)
            __AgentStartedDelegate = cb;

            MacHelpers.LibLaunchAgent(HELPER_LABEL, (int port, UInt64 secret) =>
            {
                Logging.Info("GOT BACK PORT => " + port);
                __AgentStartedDelegate(port, secret);
            });
        }
Ejemplo n.º 7
0
        private static string GetInstalledVersion()
        {
            NSDictionary dict = MacHelpers.SMJobDictionary(HELPER_LABEL);

            if (dict == null)
            {
                return(null);
            }

            var     obj = dict.ValueForKey(new NSString("ProgramArguments"));
            NSArray programArguments = (NSArray)obj;
            var     programPath      = programArguments.GetItem <NSString>(0).ToString();

            return(MacHelpers.GetBundleVersion(programPath));
        }