Пример #1
0
 private void btnSetDefault_Click(object sender, EventArgs e)
 {
     if (RPMessageBox.ShowQuestion("This will remove all entries and replace them with the default recording folder - are you sure?", "Revert to default recording path") == DialogResult.Yes)
     {
         SetDefaultRecordingPath();
     }
 }
Пример #2
0
 private void btnHelpWin7Libraries_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (RPMessageBox.ShowQuestion("If this box is checked, Remote Potato ignores this list and uses the folders in your Windows 7 " + CollectionName + " library instead.\r\n\r\nDo you wish to edit these folders now?", "Help on Windows 7 " + CollectionName + " library") == System.Windows.Forms.DialogResult.Yes)
     {
         RPMessageBox.ShowAlert("Remote Potato will open a Windows Explorer window.  To add/remove " + CollectionName + " folders, you should look for the heading 'Libraries' in the left-hand column, then right-click the word '" + CollectionName + "' and choose 'Properties'.");
         string target = "explorer.exe";
         System.Diagnostics.Process.Start(target);
     }
 }
Пример #3
0
        void AddFirewallRules()
        {
            // Add firewall rules
            if (!FirewallHelper.AddFirewallRules())
            {
                RPMessageBox.ShowAlert("The firewall rules could not be added to Windows Firewall.\r\n\r\nYou may need to manually add incoming and outgoing rules for your ports.");
            }

            Settings.Default.HaveOfferedWindowsFirewallForPort = Convert.ToInt32(Settings.Default.RPPortWithLiveTV);
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            if (RPMessageBox.ShowQuestion("Remote Potato for iOS allows you to stream all your music, pictures and video directly to your iPhone or iPad.\r\n\r\nWould you like to read more about the app now?", "Remote Potato for iPhone/iPad") == System.Windows.Forms.DialogResult.Yes)
            {
                ShowIOSAppWebPage();
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
Пример #5
0
        // Generic Methods - for a named service
        static bool SetServiceLogon(string ServiceName, string AccountName, string Password, bool PredefinedAccount, ref string ErrorText)
        {
            string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName);

            using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
            {
                object[] wmiParams = new object[11];

                if (PredefinedAccount)
                {
                    wmiParams[6] = "LocalSystem";
                    wmiParams[7] = "";
                }
                else
                {
                    // Must be passed local account syntax - adjust if need be
                    if (!AccountName.Contains("\\"))
                    {
                        AccountName = ".\\" + AccountName;
                    }

                    wmiParams[6] = AccountName; // provided by user
                    wmiParams[7] = Password;    // provided by user
                }

                object invokeResult = null;
                try
                {
                    invokeResult = service.InvokeMethod("Change", wmiParams);  //http://msdn.microsoft.com/en-us/library/aa384901
                }
                catch (ManagementException mex)
                {
                    if (mex.ErrorCode.ToString().Equals("NotFound"))
                    {
                        RPMessageBox.ShowAlert("The Remote Potato Service could not be found - please try re-installing Remote Potato");
                    }
                    return(false);
                }
                catch
                {
                    return(false);
                }

                // Return true if result code is 0
                int resultCode;
                if (!int.TryParse(invokeResult.ToString(), out resultCode))
                {
                    ErrorText = "Non-numerical result code from Change() method.";
                    return(false);
                }

                ErrorText = ChangeServiceErrorMessage(resultCode);
                return(resultCode == 0);
            }
        }
Пример #6
0
        private void llAddFirewall_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (RPMessageBox.ShowQuestion("Most connection problems can be solved by either changing the settings on either your router or Windows Firewall.\r\n\r\nWould you like to read more about this online now?", "Solve Connection Problems") == DialogResult.No)
            {
                return;
            }

            string target = "http://forums.fatattitude.com/viewforum.php?f=12";

            System.Diagnostics.Process.Start(target);
        }
Пример #7
0
        // SHOW ROUTER SETTINGS
        private void btnShowRouterSettings_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if ((nathelper == null) || (!nathelper.GatewayFound))
            {
                RPMessageBox.ShowAlert("A compatible router (UPnP) could not be found on your network.");
                return;
            }

            string strMappings = nathelper.ListMappings();

            RPMessageBox.Show(strMappings, "Router Port Mappings");
        }
Пример #8
0
        void AddPortForwardingRules()
        {
            if (nathelper == null)
            {
                return;
            }
            if (!nathelper.GatewayFound)
            {
                return;
            }

            ChangeActivityStatus("Checking Local IP Address...");

            if (string.IsNullOrWhiteSpace(LocalIP))
            {
                ChangeBlurbText("Remote Potato could not get the local IP address, so could not set up your router.");
            }
            else
            {
                ChangeActivityStatus("Checking for router...");
                string txtError = "";

                // Manual rules
                int    lowestStreamPort  = Convert.ToInt32(Settings.Default.SilverlightStreamingPort);
                int    highestStreamPort = lowestStreamPort + Settings.Default.SilverlightStreamingNumberOfPorts - 1;
                string txtManualRules    = String.Format("You need to forward port {0} and ports {1}-{2} to IP address {3} (this computer)\r\n\r\nNeed help? Visit www.portforward.com", Settings.Default.RPPortWithLiveTV.ToString(), lowestStreamPort.ToString(), highestStreamPort.ToString(), LocalIP);

                if (!nathelper.Discover(ref txtError))
                {
                    ChangeBlurbText("Remote Potato could not find a router on your local network - have you disabled UPnP on your router?\r\n\r\n" + txtManualRules);
                }
                else
                {
                    ChangeActivityStatus("Setting up router...");
                    if (nathelper.ForwardRPPorts(LocalIP) == NATHelper.NatHelperReponseCodes.OK)
                    {
                        RPMessageBox.Show("Your router has been automatically set up for Remote Potato.\r\nClick OK to verify the changes.");
                        // TODO:
                        CheckPortForwarding();
                    }
                    else
                    {
                        ChangeBlurbText("Your router could not be automatically set up (see the debug log for more information)\r\n\r\n." + txtManualRules);
                    }
                }

                nathelper = null;
            }

            // Finished - hide mask
            this.Invoke(new Action(HideActivityMask));
        }
Пример #9
0
        private void wizardPages1_Deselecting(object sender, TabControlCancelEventArgs e)
        {
            bool   ShouldCancel = false;
            string CancelReason = "";

            switch (e.TabPageIndex)
            {
            case 0:
                TryMoveFromStep0(ref ShouldCancel, ref CancelReason);
                break;

            case 1:
                TryMoveFromStep1(ref ShouldCancel, ref CancelReason);
                break;

            case 2:
                TryMoveFromStep2(ref ShouldCancel, ref CancelReason);
                break;

            case 3:
                TryMoveFromStep3(ref ShouldCancel, ref CancelReason);
                break;

            case 4:
                TryMoveFromStep4(ref ShouldCancel, ref CancelReason);
                break;

            case 5:
                TryMoveFromStep5(ref ShouldCancel, ref CancelReason);
                break;
            }

            e.Cancel = ShouldCancel;

            if (e.Cancel)
            {
                string strDisplayReason = (string.IsNullOrWhiteSpace(CancelReason)) ? "A value was incorrect, or left blank.\r\n\r\nPlease check all the values you have entered on this page and try again." : CancelReason;
                RPMessageBox.ShowAlert(strDisplayReason);

                // Re-adjust page index
                if (movingForward)
                {
                    PageIndex--;
                }
                else
                {
                    PageIndex++;
                }
            }
        }
Пример #10
0
        // Add a folder and refresh box
        void addFolder(string txtPath)
        {
            if (string.IsNullOrEmpty(txtPath))
            {
                return;
            }
            if (listviewContainsText(txtPath))
            {
                RPMessageBox.ShowAlert("You have already added this folder.");
                return;
            }

            Folders.Add(txtPath);
            lvRecTVFolders.Items.Add(txtPath);
        }
Пример #11
0
        public static void AskThenAddFirewallRules()
        {
            if (RPMessageBox.ShowQuestion("Do you use Windows Firewall?  If so, we can add rules to your firewall to allow Remote Potato to be accessed over the Internet.  You will only ever need to do this once, unless you change port numbers.\r\n\r\nDo you want to do this now?", "Add Firewall Rules?") == DialogResult.No)
            {
                return;
            }

            if (AddFirewallRules())
            {
                RPMessageBox.Show("The rules were successfully added to Windows Firewall.\r\n\r\nRemember, you do not need to do this again unless you change port numbers.");
            }
            else
            {
                RPMessageBox.ShowAlert("There was an error adding the rules to Windows Firewall - see debug log for more information.\r\n\r\nClick the 'Re-add firewall rules' button to try this again.");
            }
        }
Пример #12
0
        void ReserveURLForLiveTVPort()
        {
            URLReserver reserver   = new URLReserver();
            int         ResultCode = reserver.ReserveUrl(Convert.ToInt32(Settings.Default.RPPortWithLiveTV), "/", true);

            if (ResultCode == 0)
            {
                Functions.WriteLineToLogFile("URLReserver: 0 OK");
                Settings.Default.LastSetSecurityForLiveTVPort = Convert.ToInt32(Settings.Default.RPPortWithLiveTV);
            }
            else
            {
                Functions.WriteLineToLogFile("URLReserver: NOT OK");
                RPMessageBox.ShowAlert("Could not reserve a Url for Remote Potato server - error code " + ResultCode.ToString());
            }
        }
Пример #13
0
        void AddFolder()
        {
            if (lvRecTVFolders.Items.Count > (MAX_FOLDERS - 1))
            {
                RPMessageBox.ShowAlert("You may only add up to " + MAX_FOLDERS.ToString() + " folders.");
                return;
            }

            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.ShowNewFolderButton = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                addFolder(dialog.SelectedPath);
            }
        }
Пример #14
0
        void AddPath()
        {
            if (lvRecTVFolders.Items.Count > (MAX_FOLDERS - 1))
            {
                RPMessageBox.ShowAlert("You may only add up to " + MAX_FOLDERS.ToString() + " folders.");
                return;
            }


            FormInputBox fInputBox = new FormInputBox("Add path to folder", "Enter the path to a folder - e.g. \\\\SERVER\\SHARENAME", "\\SERVER\\SHARE_NAME");

            if (fInputBox.ShowDialog() == DialogResult.OK)
            {
                if (!(string.IsNullOrWhiteSpace(fInputBox.Value)))
                {
                    addFolder(fInputBox.Value);
                }
            }
        }
Пример #15
0
        static bool SetServiceStartupType(string ServiceName, bool startWithWindows, ref string ErrorText)
        {
            string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName);

            using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
            {
                object[] wmiParams = new object[1];

                wmiParams[0] = startWithWindows ? "Automatic" : "Manual";

                object invokeResult = null;
                try
                {
                    invokeResult = service.InvokeMethod("ChangeStartMode", wmiParams);  //http://msdn.microsoft.com/en-us/library/aa384901
                }
                catch (ManagementException mex)
                {
                    if (mex.ErrorCode.ToString().Equals("NotFound"))
                    {
                        RPMessageBox.ShowAlert("The Remote Potato Service could not be found - please try re-installing Remote Potato");
                    }
                    return(false);
                }
                catch
                {
                    return(false);
                }

                // Return true if result code is 0
                int resultCode;
                if (!int.TryParse(invokeResult.ToString(), out resultCode))
                {
                    ErrorText = "Non-numerical result code from Change() method.";
                    return(false);
                }

                ErrorText = ChangeServiceErrorMessage(resultCode);
                return(resultCode == 0);
            }
        }
Пример #16
0
        void TryToChangeMediaLibraryAccount()
        {
            lblStatus.Text = "Please wait - making changes...";
            Application.DoEvents();

            string AccountName = txtMediaLibraryUsername.Text.Trim();
            string Password    = txtMediaLibraryPassword.Text.Trim();

            if (string.IsNullOrEmpty(AccountName))
            {
                lblStatus.Text = "You must enter the details of a user of this machine.";
                return;
            }

            if (string.IsNullOrEmpty(Password))
            {
                // Services require a login with a password if limited in registry  see http://stackoverflow.com/questions/1047854/cant-run-a-service-under-an-account-which-has-no-password
                if (Functions.IsBlankPasswordLimitedOnMachine)
                {
                    if (RPMessageBox.ShowQuestion("Blank passwords for services are currently limited on this machine.\r\n\r\nDo you wish to lift this security restriction so that Remote Potato can run?", "Allow blank passwords on machine?")
                        == DialogResult.Yes)
                    {
                        Functions.SetBlankPasswordLimitOnMachine(false);
                    }
                    else
                    {
                        RPMessageBox.Show("To allow Remote Potato to run, please use an account that has a Username and a Password");
                        return;
                    }
                }
            }
            else  // re-instate blank password limit?
            {
                if (!Functions.IsBlankPasswordLimitedOnMachine)
                {
                    if (RPMessageBox.ShowQuestion("Blank passwords for services are currently allowed on this machine.  Unless you require this security relaxation for other services or remotely access user accounts on this machine that have no password, you should re-enable this security restriction.\r\n\r\nDo you wish to forbid blank passwords for services?", "Forbid blank passwords on machine?")
                        == DialogResult.Yes)
                    {
                        Functions.SetBlankPasswordLimitOnMachine(true);
                    }
                }
            }

            if (!ValidateCredentials(AccountName, Password))
            {
                lblStatus.Text = "The log on details that you entered were incorrect.";
                return;
            }



            //if (!SetServiceLogon("Remote Potato Service", AccountName, Password, true)) return;
            string strErrorText = string.Empty;

            if (!ServiceManager.SetRPServiceLogon(AccountName, Password, false, ref strErrorText))
            {
                lblStatus.Text = "Could not use this account - please check the details:" + strErrorText;
                return;
            }

            if (!SetLogOnAsServiceRight(AccountName))
            {
                RPMessageBox.ShowAlert("Could not add required security priviliges to this account - please check that you running as an Administrator, and that you have entered the details correctly.");
                lblStatus.Text = "Error setting priviliges.";
                return;
            }

            lblStatus.Text = string.Empty;
            CommitAndClose();
        }