[chronojump] compujump server connected/disconnected message
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] compujump server connected/disconnected message
- Date: Fri, 17 Nov 2017 15:46:34 +0000 (UTC)
commit 5b380abbc7eb2ca459997b130540a705ce646d7f
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Nov 17 16:41:05 2017 +0100
compujump server connected/disconnected message
glade/dialog_person_popup.glade | 60 ++++++++++++++++++++++++++++++++++++++-
images/gtk-apply.png | Bin 0 -> 314 bytes
src/Makefile.am | 1 +
src/constants.cs | 1 +
src/gui/dialogPersonPopup.cs | 23 ++++++++++++++-
src/gui/networks.cs | 21 +++++++++++--
src/json.cs | 10 ++++++
7 files changed, 110 insertions(+), 6 deletions(-)
---
diff --git a/glade/dialog_person_popup.glade b/glade/dialog_person_popup.glade
index 7a6bd11..5fec012 100644
--- a/glade/dialog_person_popup.glade
+++ b/glade/dialog_person_popup.glade
@@ -61,6 +61,64 @@
<widget class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkVBox" id="vbox7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkHBox" id="hbox6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkImage" id="image_server_connected_yes">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkImage" id="image_server_connected_no">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_server_connected">
+ <property name="visible">True</property>
+ <property name="can_focus">False</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">0</property>
+ </packing>
+ </child>
<child>
<widget class="GtkButton" id="button_close">
<property name="visible">True</property>
@@ -105,7 +163,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
diff --git a/images/gtk-apply.png b/images/gtk-apply.png
new file mode 100644
index 0000000..ca636c4
Binary files /dev/null and b/images/gtk-apply.png differ
diff --git a/src/Makefile.am b/src/Makefile.am
index 05ea577..b1aacd9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -439,6 +439,7 @@ RESOURCES = \
../images/pulse_menu.png,pulse_menu.png \
../images/multichronopic_menu.png,multichronopic_menu.png \
../images/force_sensor_menu.png,force_sensor_menu.png \
+ ../images/gtk-apply.png,gtk-apply.png \
../images/gtk-cancel.png,gtk-cancel.png \
../images/gtk-zoom-fit.png,gtk-zoom-fit.png \
../images/gtk-zoom-in.png,gtk-zoom-in.png \
diff --git a/src/constants.cs b/src/constants.cs
index 88708ec..8f8dcc4 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -198,6 +198,7 @@ public class Constants
public static string RFIDDisconnectedMessage = Catalog.GetString("RFID cable has been disconnected!")
+ "\n\n" +
Catalog.GetString("Please, connect it and restart Chronojump.");
public static string RFIDNotInServerMessage = Catalog.GetString("This RFID is not registered on
server.");
+ public static string ServerDisconnectedMessage = Catalog.GetString("Server is disconnected.");
//server
public const string ServerPingTable = "SPing";
diff --git a/src/gui/dialogPersonPopup.cs b/src/gui/dialogPersonPopup.cs
index 07b2600..2cd094b 100644
--- a/src/gui/dialogPersonPopup.cs
+++ b/src/gui/dialogPersonPopup.cs
@@ -36,6 +36,10 @@ public class DialogPersonPopup
[Widget] Gtk.Notebook notebook;
[Widget] Gtk.VBox vbox_tasks_parametrized;
+ [Widget] Gtk.Label label_server_connected;
+ [Widget] Gtk.Image image_server_connected_yes;
+ [Widget] Gtk.Image image_server_connected_no;
+
private List<Task> list_tasks_fixed; //This list has "R,L" separated
private List<Gtk.Button> list_buttons_start;
private List<Gtk.Button> list_buttons_done;
@@ -48,7 +52,8 @@ public class DialogPersonPopup
public Button Fake_button_person_logout;
public bool Visible;
- public DialogPersonPopup (int personID, string name, string rfid, List<Task> tasks,
List<StationCount> stationsCount)
+ public DialogPersonPopup (int personID, string name, string rfid,
+ List<Task> tasks, List<StationCount> stationsCount, bool serverConnected)
{
Glade.XML gladeXML;
gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "dialog_person_popup.glade",
"dialog_person_popup", null);
@@ -70,6 +75,22 @@ public class DialogPersonPopup
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_person_logout.png");
image_person_logout.Pixbuf = pixbuf;
+ pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "gtk-apply.png");
+ image_server_connected_yes.Pixbuf = pixbuf;
+ pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "gtk-cancel.png");
+ image_server_connected_no.Pixbuf = pixbuf;
+
+ if(serverConnected)
+ {
+ label_server_connected.Text = "Server is connected";
+ image_server_connected_yes.Visible = true;
+ image_server_connected_no.Visible = false;
+ } else {
+ label_server_connected.Text = Constants.ServerDisconnectedMessage;
+ image_server_connected_yes.Visible = false;
+ image_server_connected_no.Visible = true;
+ }
+
string photoFile = Util.GetPhotoFileName(false, personID);
if(File.Exists(photoFile))
{
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 544f86e..f5fe714 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -469,7 +469,20 @@ public partial class ChronoJumpWindow
LogB.Information("RFID person does not exist locally!!");
Person pServer = json.GetPersonByRFID(capturedRFID);
- if(pServer.UniqueID == -1) {
+
+ if(! json.Connected) {
+ LogB.Information("Server is disconnected!");
+ if(dialogMessageNotAtServer == null || ! dialogMessageNotAtServer.Visible)
+ {
+ dialogMessageNotAtServer = new DialogMessage(
+ Constants.MessageTypes.WARNING,
+ Constants.ServerDisconnectedMessage
+ ); //GTK
+
+ compujumpPersonLogoutDo();
+ }
+ }
+ else if(pServer.UniqueID == -1) {
LogB.Information("Person NOT found on server!");
if(dialogMessageNotAtServer == null || ! dialogMessageNotAtServer.Visible)
{
@@ -618,10 +631,10 @@ public partial class ChronoJumpWindow
List<StationCount> stationsCount =
json.GetOtherStationsWithPendingTasks(currentPerson.UniqueID, configChronojump.CompujumpStationID);
//4) show dialog
- showDialogPersonPopup(tasks, stationsCount);
+ showDialogPersonPopup(tasks, stationsCount, json.Connected);
}
- private void showDialogPersonPopup(List<Task> tasks, List<StationCount> stationsCount)
+ private void showDialogPersonPopup(List<Task> tasks, List<StationCount> stationsCount, bool
serverConnected)
{
if(dialogPersonPopup != null)
dialogPersonPopup.DestroyDialog();
@@ -630,7 +643,7 @@ public partial class ChronoJumpWindow
dialogMessageNotAtServer.on_close_button_clicked(new object(), new EventArgs());
dialogPersonPopup = new DialogPersonPopup(
- currentPerson.UniqueID, currentPerson.Name, capturedRFID, tasks,
stationsCount);
+ currentPerson.UniqueID, currentPerson.Name, capturedRFID, tasks,
stationsCount, serverConnected);
dialogPersonPopup.Fake_button_start_task.Clicked -= new EventHandler(compujumpTaskStart);
dialogPersonPopup.Fake_button_start_task.Clicked += new EventHandler(compujumpTaskStart);
diff --git a/src/json.cs b/src/json.cs
index 70892d0..8658296 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -31,6 +31,7 @@ using Mono.Unix;
public class Json
{
+ private bool connected; //know if server is connected. Do it when there's a change on RFID (pulse)
public string ResultMessage;
static string serverUrl = "http://api.chronojump.org:8080";
//string serverUrl = "http://192.168.200.1:8080";
@@ -277,6 +278,7 @@ public class Json
public Person GetPersonByRFID(string rfid)
{
+ connected = false;
Person person = new Person(-1);
// Create a request using a URL that can receive a post.
@@ -338,6 +340,7 @@ public class Json
person = personDeserialize(responseFromServer);
}
+ connected = true;
return person;
}
@@ -403,6 +406,8 @@ public class Json
public List<Task> GetTasks(int personID, int stationID)
{
+ connected = false;
+
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create (serverUrl + "/getTasks");
@@ -452,6 +457,8 @@ public class Json
LogB.Information("GetTasks: " + responseFromServer);
+ connected = true;
+
if(responseFromServer == "" || responseFromServer == "[]")
{
LogB.Information(" Empty ");
@@ -958,6 +965,9 @@ public class Json
return true;
}
+ public bool Connected {
+ get { return connected; }
+ }
~Json() {}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]