moel@150: /* moel@150: moel@150: Version: MPL 1.1/GPL 2.0/LGPL 2.1 moel@150: moel@150: The contents of this file are subject to the Mozilla Public License Version moel@150: 1.1 (the "License"); you may not use this file except in compliance with moel@150: the License. You may obtain a copy of the License at moel@150: moel@150: http://www.mozilla.org/MPL/ moel@150: moel@150: Software distributed under the License is distributed on an "AS IS" basis, moel@150: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License moel@150: for the specific language governing rights and limitations under the License. moel@150: moel@150: The Original Code is the Open Hardware Monitor code. moel@150: moel@150: The Initial Developer of the Original Code is moel@150: Michael Möller . moel@150: Portions created by the Initial Developer are Copyright (C) 2009-2010 moel@150: the Initial Developer. All Rights Reserved. moel@150: moel@150: Contributor(s): moel@150: moel@150: Alternatively, the contents of this file may be used under the terms of moel@150: either the GNU General Public License Version 2 or later (the "GPL"), or moel@150: the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), moel@150: in which case the provisions of the GPL or the LGPL are applicable instead moel@150: of those above. If you wish to allow use of your version of this file only moel@150: under the terms of either the GPL or the LGPL, and not to allow others to moel@150: use your version of this file under the terms of the MPL, indicate your moel@150: decision by deleting the provisions above and replace them with the notice moel@150: and other provisions required by the GPL or the LGPL. If you do not delete moel@150: the provisions above, a recipient may use your version of this file under moel@150: the terms of any one of the MPL, the GPL or the LGPL. moel@150: moel@150: */ moel@150: moel@150: using System; moel@150: using System.Drawing; moel@150: using System.IO; moel@150: using System.Net; moel@150: using System.Text; moel@150: using System.Windows.Forms; moel@150: moel@150: namespace OpenHardwareMonitor.GUI { moel@150: public partial class ReportForm : Form { moel@150: moel@150: private string report; moel@150: moel@150: public ReportForm() { moel@150: InitializeComponent(); moel@150: try { moel@150: titleLabel.Font = new Font(SystemFonts.DefaultFont, FontStyle.Bold); moel@150: reportTextBox.Font = new Font(FontFamily.GenericMonospace, moel@150: SystemFonts.DefaultFont.Size); moel@150: } catch { } moel@150: } moel@150: moel@150: public string Report { moel@150: get { return report; } moel@150: set { moel@150: report = value; moel@150: reportTextBox.Text = report; moel@150: } moel@150: } moel@150: moel@150: private void sendButton_Click(object sender, EventArgs e) { moel@150: Version version = typeof(CrashForm).Assembly.GetName().Version; moel@150: WebRequest request = WebRequest.Create( moel@150: "http://openhardwaremonitor.org/report.php"); moel@150: request.Method = "POST"; moel@150: request.Timeout = 5000; moel@150: request.ContentType = "application/x-www-form-urlencoded"; moel@150: moel@150: string report = moel@206: "type=hardware&" + moel@206: "version=" + Uri.EscapeDataString(version.ToString()) + "&" + moel@206: "report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" + moel@206: "comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" + moel@206: "email=" + Uri.EscapeDataString(emailTextBox.Text); moel@150: byte[] byteArray = Encoding.UTF8.GetBytes(report); moel@150: request.ContentLength = byteArray.Length; moel@150: moel@150: try { moel@150: Stream dataStream = request.GetRequestStream(); moel@150: dataStream.Write(byteArray, 0, byteArray.Length); moel@150: dataStream.Close(); moel@150: moel@150: WebResponse response = request.GetResponse(); moel@150: dataStream = response.GetResponseStream(); moel@150: StreamReader reader = new StreamReader(dataStream); moel@150: string responseFromServer = reader.ReadToEnd(); moel@150: reader.Close(); moel@150: dataStream.Close(); moel@150: response.Close(); moel@150: moel@150: Close(); moel@150: } catch (WebException) { moel@150: MessageBox.Show("Sending the hardware report failed.", "Error", moel@150: MessageBoxButtons.OK, MessageBoxIcon.Error); moel@150: } moel@150: } moel@150: } moel@150: }