[chronojump] Send log adds version name and email is stored on database
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Send log adds version name and email is stored on database
- Date: Tue, 27 Jan 2015 15:32:53 +0000 (UTC)
commit ecbbc703b43bbea8c0440bc46b1e926c5bc784cf
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jan 27 16:32:24 2015 +0100
Send log adds version name and email is stored on database
glade/chronojump.glade | 248 ++++++++++++++++++++++++++++++++++++++-------
po/POTFILES.in | 1 +
src/chronojump.cs | 16 +--
src/gui/error.cs | 26 ++++-
src/json.cs | 5 +-
src/sqlite/main.cs | 13 ++-
src/sqlite/preferences.cs | 1 +
src/util.cs | 12 ++
src/utilAll.cs | 7 ++
9 files changed, 270 insertions(+), 59 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index e2cecfa..290ebea 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6401,6 +6401,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -7176,6 +7182,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -8203,6 +8215,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -8871,6 +8889,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -19069,6 +19093,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -19645,6 +19675,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -20713,6 +20749,12 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -20838,6 +20880,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -24637,54 +24685,109 @@ comments</property>
<property name="can_focus">False</property>
<property name="border_width">4</property>
<child>
- <widget class="GtkVBox" id="vbox1">
+ <widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">8</property>
- <child>
- <widget class="GtkButton" id="button_send_log">
- <property name="label">Send error log</property>
- <property name="width_request">180</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <signal name="clicked" handler="on_button_send_log_clicked" swapped="no"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0.69999998807907104</property>
+ <property name="shadow_type">out</property>
<child>
- <widget class="GtkHBox" id="hbox1">
+ <widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">8</property>
+ <property name="border_width">8</property>
+ <property name="spacing">6</property>
<child>
- <widget class="GtkImage" id="image_send_log_no">
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-no</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Your email</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry_send_log">
+ <property name="width_request">175</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button_send_log">
+ <property name="label">Send error log</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <signal name="clicked" handler="on_button_send_log_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkImage" id="image_send_log_no">
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-no</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkImage" id="image_send_log_yes">
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-yes</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <widget class="GtkImage" id="image_send_log_yes">
- <property name="can_focus">False</property>
- <property name="stock">gtk-yes</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
<widget class="GtkLabel" id="label_send_log_message">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -24692,14 +24795,15 @@ comments</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
+ </child>
+ <child>
+ <placeholder/>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="type">label_item</property>
</packing>
</child>
</widget>
@@ -30066,6 +30170,42 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -32022,6 +32162,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -32636,6 +32782,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -35216,6 +35368,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -35456,6 +35614,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -35711,6 +35875,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 973c010..44f13ba 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -27,6 +27,7 @@ src/gui/convertWeight.cs
src/gui/encoder.cs
src/gui/encoderConfiguration.cs
src/gui/encoderTreeviews.cs
+src/gui/error.cs
src/gui/evaluator.cs
src/gui/event.cs
src/gui/eventExecute.cs
diff --git a/src/chronojump.cs b/src/chronojump.cs
index fe9d48c..9b11a2d 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -25,7 +25,6 @@ using Glade;
using Mono.Unix;
using System.IO; //"File" things
using System.Threading;
-using System.Reflection; // Read Version
using System.Diagnostics; //Process
using System.Collections; //ArrayList
@@ -208,7 +207,7 @@ public class ChronoJump
}
//print version of chronojump
- progVersion = readVersion();
+ progVersion = UtilAll.ReadVersion();
LogB.Information("Chronojump version: {0}", progVersion);
@@ -456,7 +455,7 @@ public class ChronoJump
LogB.Warning("Problem with splash win");
}
- versionAvailable = Server.Ping(true, progName, readVersion()); //doInsertion
+ versionAvailable = Server.Ping(true, progName, UtilAll.ReadVersion()); //doInsertion
LogB.Debug("--4--");
splashShowButton = false;
@@ -484,7 +483,6 @@ public class ChronoJump
errorWin.Button_accept.Clicked += new
EventHandler(on_message_boot_accepted_quit);
} else {
errorWin = ErrorWindow.Show(messageToShowOnBoot);
- errorWin.Show_button_open_docs_folder();
errorWin.Show_send_log();
errorWin.Button_accept_label(Catalog.GetString("Open Chronojump"));
errorWin.Button_accept.Clicked += new
EventHandler(on_message_boot_accepted_continue);
@@ -538,7 +536,7 @@ public class ChronoJump
Sqlite.CreateFile();
Sqlite.CreateTables(true); //server
LogB.SQL("Created blank database! Exiting");
- string myVersion = readVersion();
+ string myVersion = UtilAll.ReadVersion();
LogB.Warning("CAUTION: client info about versionAvailable (on server): ", myVersion);
SqlitePreferences.Update ("availableVersion", myVersion, false);
LogB.Information("Maybe you don't want to show this version on pings, change it to
last stable published version");
@@ -663,7 +661,7 @@ public class ChronoJump
messageChrashedBefore = "\n" +
string.Format(Catalog.GetString("Chronojump {0} crashed before."), progVersion) +
"\n\n" +
- Catalog.GetString("Please, open docs folder and follow instructions on
'chronojump_crash.pdf' in order to be fixed fast.") + "\n\n" +
+ Catalog.GetString("Please, fill your email and click on 'Send error log' in order to
fix this fast and contact you if appropiate.") + "\n\n" +
Catalog.GetString("Your help is needed.") + "\n";
@@ -713,12 +711,6 @@ public class ChronoJump
return returnString;
}
- private static string readVersion() {
- Version version = Assembly.GetExecutingAssembly().GetName().Version;
- return version.ToString();
- }
-
-
private void createRunningFileName(string runningFileName) {
TextWriter writer = File.CreateText(runningFileName);
writer.WriteLine(Process.GetCurrentProcess().Id);
diff --git a/src/gui/error.cs b/src/gui/error.cs
index 7899913..28c0637 100644
--- a/src/gui/error.cs
+++ b/src/gui/error.cs
@@ -26,7 +26,7 @@ using Glade;
using GLib; //for Value
using System.Text; //StringBuilder
using System.Collections; //ArrayList
-
+using Mono.Unix;
public class ErrorWindow
{
@@ -38,6 +38,8 @@ public class ErrorWindow
[Widget] Gtk.Button button_open_docs_folder;
[Widget] Gtk.Image image_send_log_no;
[Widget] Gtk.Image image_send_log_yes;
+ [Widget] Gtk.Entry entry_send_log;
+ [Widget] Gtk.Button button_send_log;
[Widget] Gtk.Label label_send_log_message;
string table;
@@ -83,19 +85,35 @@ public class ErrorWindow
//need this for continue execution on chronojump startup. See src/chronojump.cs
button_accept.Click();
}
-
- public void Show_send_log() {
+
+ string emailStored;
+ public void Show_send_log()
+ {
+ emailStored = SqlitePreferences.Select("email");
+ if(emailStored != null && emailStored != "" && emailStored != "0")
+ entry_send_log.Text = emailStored;
+
hbox_send_log.Show();
}
private void on_button_send_log_clicked (object o, EventArgs args)
{
+ string email = entry_send_log.Text.ToString();
+ //email can be validated with Util.IsValidEmail(string)
+ //or other methods, but maybe there's no need of complexity now
+
+ //1st save email on sqlite
+ if(email != null && email != "" && email != "0" && email != emailStored)
+ SqlitePreferences.Update("email", email, false);
+
+ //2nd send Json
Json js = new Json();
- bool success = js.PostCrashLog();
+ bool success = js.PostCrashLog(email);
if(success) {
image_send_log_yes.Show();
LogB.Information(js.ResultMessage);
} else {
+ button_send_log.Label = Catalog.GetString("Try again");
image_send_log_no.Show();
LogB.Error(js.ResultMessage);
}
diff --git a/src/json.cs b/src/json.cs
index f1dcd81..3636a0b 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -35,11 +35,10 @@ public class Json
ResultMessage = "";
}
- public bool PostCrashLog()
+ public bool PostCrashLog(string email)
{
string serverUrl = "http://api.chronojump.org:8080";
string filePath = UtilAll.GetLogFileOld();
- string email = "test test com";
if(! File.Exists(filePath)) {
this.ResultMessage = Catalog.GetString("Could not send file.\nIt does not exist.");
@@ -47,7 +46,7 @@ public class Json
}
// Create a request using a URL that can receive a post.
- WebRequest request = WebRequest.Create (serverUrl + "/backtrace/" + email);
+ WebRequest request = WebRequest.Create (serverUrl + "/backtrace/" + UtilAll.ReadVersion() +
"-" + email);
// Set the Method property of the request to POST.
request.Method = "POST";
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index e16c4a0..8039b9c 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -73,7 +73,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "1.19";
+ static string lastChronojumpDatabaseVersion = "1.20";
public Sqlite() {
}
@@ -1741,6 +1741,16 @@ class Sqlite
currentVersion = "1.19";
}
+ if(currentVersion == "1.19") {
+ LogB.SQL("Preferences: added user email");
+
+ Sqlite.Open();
+ SqlitePreferences.Insert ("email", "");
+ SqlitePreferences.Update ("databaseVersion", "1.20", true);
+ Sqlite.Close();
+
+ currentVersion = "1.20";
+ }
}
@@ -1885,6 +1895,7 @@ class Sqlite
SqliteExecuteAuto.addChronojumpProfileAndBilateral();
//changes [from - to - desc]
+ //1.19 - 1.20 Converted DB to 1.20 Preferences: added user email
//1.18 - 1.19 Converted DB to 1.19 Preferences deleted showHeight, added showStiffness
//1.17 - 1.18 Converted DB to 1.18 deleted Negative runInterval runs (bug from last version)
//1.16 - 1.17 Converted DB to 1.17 Deleted Max jump (we already have "Free")
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 8a2c8bb..3281d02 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -81,6 +81,7 @@ class SqlitePreferences : Sqlite
Insert ("RGraphsTranslate", "True");
Insert ("useHeightsOnJumpIndexes", "True");
Insert ("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.BESTMEANPOWER.ToString());
+ Insert ("email", "");
}
public static void Insert(string myName, string myValue)
diff --git a/src/util.cs b/src/util.cs
index e7177c8..a7fae04 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1612,4 +1612,16 @@ public class Util
return sb.ToString();
}
+ //test if an email is valid
+ //http://stackoverflow.com/questions/1365407/c-sharp-code-to-validate-email-address
+ public static bool IsValidEmail(string email)
+ {
+ try {
+ var addr = new System.Net.Mail.MailAddress(email);
+ return addr.Address == email;
+ }
+ catch {
+ return false;
+ }
+ }
}
diff --git a/src/utilAll.cs b/src/utilAll.cs
index ee0ba3f..7444098 100644
--- a/src/utilAll.cs
+++ b/src/utilAll.cs
@@ -21,12 +21,19 @@
using System;
using System.Diagnostics; //for detect OS
using System.IO; //for detect OS
+using System.Reflection; // Read Version
//this class tries to be a space for methods that are used in different classes
//in chronojump and chronojump_mini
//we do not use util.cs in mini because it has lot of calls to other files
public class UtilAll
{
+ public static string ReadVersion() {
+ Version version = Assembly.GetExecutingAssembly().GetName().Version;
+ return version.ToString();
+ }
+
+
//Adapted from Mono. A developer's notebook. p 244
//this is used in chronojump for working with the ports,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]