Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        /// <returns>Crash report as string</returns>
        public void Write(Exception e)
        {
            ExceptionReportInfo info = new ExceptionReportInfo {MainException = e};
            ExceptionReportGenerator reportGenerator = new ExceptionReportGenerator(info);
            ExceptionReport report = reportGenerator.CreateExceptionReport();

            string crashDir = Path.Combine(Preferences.instance().getProperty("application.support.path"),
                                           "CrashReporter");
            Directory.CreateDirectory(crashDir);
            using (StreamWriter outfile = new StreamWriter(Path.Combine(crashDir, DateTime.Now.Ticks + ".txt")))
            {
                outfile.Write(report.ToString());
            }
            TaskDialog prompt = new TaskDialog();
            DialogResult result = prompt.ShowCommandBox(Locale.localizedString("Do you want to report the last crash?", "Crash"),
                                                        Locale.localizedString("Do you want to report the last crash?", "Crash"),
                                                        Locale.localizedString(
                                                            "The application %@ has recently crashed. To help improve it, you can send the crash log to the author.", "Crash").Replace("%@", Preferences.instance().getProperty("application.name")),
                                                        String.Format("{0}|{1}",
                                                                      Locale.localizedString("Send", "Crash"),
                                                                      Locale.localizedString("Don't Send", "Crash")),
                                                        false, SysIcons.Error);
            if (DialogResult.OK == result)
            {
                if (0 == prompt.CommandButtonResult)
                {
                    Post(report.ToString());
                }
            }
        }
Exemplo n.º 2
0
 public DialogResult CommandBox(string title, string mainInstruction, string content,
     string expandedInfo,
     string help,
     string verificationText, string commandButtons, bool showCancelButton,
     SysIcons mainIcon,
     SysIcons footerIcon, DialogResponseHandler handler)
 {
     //BringToFront();
     TaskDialog dialog = new TaskDialog();
     dialog.HelpDelegate = delegate(string url) { Utils.StartProcess(url); };
     DialogResult result = dialog.ShowCommandBox(this, title,
                                                 mainInstruction,
                                                 content,
                                                 expandedInfo,
                                                 FormatHelp(help),
                                                 verificationText,
                                                 commandButtons,
                                                 showCancelButton,
                                                 mainIcon,
                                                 footerIcon);
     handler(dialog.CommandButtonResult, dialog.VerificationChecked);
     return result;
 }
Exemplo n.º 3
0
 public DialogResult MessageBox(string title, string message, string content,
     string expandedInfo,
     string help,
     string verificationText,
     DialogResponseHandler handler)
 {
     //BringToFront();
     TaskDialog dialog = new TaskDialog();
     dialog.HelpDelegate = delegate(string url) { Utils.StartProcess(url); };
     DialogResult result = dialog.MessageBox(this,
                                             title,
                                             message,
                                             content,
                                             expandedInfo,
                                             FormatHelp(help),
                                             verificationText,
                                             TaskDialogButtons.OK, SysIcons.Information, SysIcons.Information);
     handler(-1, dialog.VerificationChecked);
     return result;
 }
Exemplo n.º 4
0
 public DialogResult MessageBox(string title, string message, string content,
     TaskDialogButtons buttons,
     SysIcons icons)
 {
     //BringToFront();
     TaskDialog dialog = new TaskDialog();
     return dialog.MessageBox(this,
                              title,
                              message,
                              content,
                              buttons, icons);
 }
Exemplo n.º 5
-1
        public override bool isTrusted(String hostName, X509Certificate[] certs)
        {
            X509Certificate2 serverCert = ConvertCertificate(certs[0]);
            X509Chain chain = new X509Chain();
            //todo Online revocation check. Preference.
            chain.ChainPolicy.RevocationMode = X509RevocationMode.Offline; // | X509RevocationMode.Online
            chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 0, 10); // set timeout to 10 seconds
            chain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;

            for (int index = 1; index < certs.Length; index++)
            {
                chain.ChainPolicy.ExtraStore.Add(ConvertCertificate(certs[index]));
            }
            chain.Build(serverCert);

            bool isException = CheckForException(hostName, serverCert);
            if (isException)
            {
                // Exceptions always have precendence
                return true;
            }

            string errorFromChainStatus = GetErrorFromChainStatus(chain, hostName);
            bool certError = null != errorFromChainStatus;
            bool hostnameMismatch = !HostnameVerifier.CheckServerIdentity(certs[0], serverCert, hostName);

            // check if host name matches
            if (null == errorFromChainStatus && hostnameMismatch)
            {
                errorFromChainStatus = Locale.localizedString(
                    "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “%@” which could put your confidential information at risk. Would you like to connect to the server anyway?",
                    "Keychain").Replace("%@", hostName);
            }

            if (null != errorFromChainStatus)
            {
                while (true)
                {
                    TaskDialog d = new TaskDialog();
                    DialogResult r =
                        d.ShowCommandBox(Locale.localizedString("This certificate is not valid", "Keychain"),
                                         Locale.localizedString("This certificate is not valid", "Keychain"),
                                         errorFromChainStatus,
                                         null,
                                         null,
                                         Locale.localizedString("Always Trust", "Keychain"),
                                         String.Format("{0}|{1}|{2}",
                                                       Locale.localizedString("Continue", "Credentials"),
                                                       Locale.localizedString("Disconnect"),
                                                       Locale.localizedString("Show Certificate", "Keychain")),
                                         false,
                                         SysIcons.Warning, SysIcons.Information);
                    if (r == DialogResult.OK)
                    {
                        if (d.CommandButtonResult == 0)
                        {
                            if (d.VerificationChecked)
                            {
                                if (certError)
                                {
                                    //todo can we use the Trusted People and Third Party Certificate Authority Store? Currently X509Chain is the problem.
                                    AddCertificate(serverCert, StoreName.Root);
                                }
                                Preferences.instance().setProperty(hostName + ".certificate.accept",
                                                                   serverCert.SubjectName.Name);
                            }
                            return true;
                        }
                        if (d.CommandButtonResult == 1)
                        {
                            return false;
                        }
                        if (d.CommandButtonResult == 2)
                        {
                            X509Certificate2UI.DisplayCertificate(serverCert);
                        }
                    }
                }
            }
            return true;
        }