[chronojump] warning if video cannot be moved
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] warning if video cannot be moved
- Date: Fri, 18 Jan 2013 11:28:47 +0000 (UTC)
commit 250cfa13fd0454c179ab9cbe5fdec03b9ecd9fa7
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jan 18 12:28:32 2013 +0100
warning if video cannot be moved
src/gui/chronojump.cs | 23 +++++++++++++++--------
src/util.cs | 14 +++++++++-----
2 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index ccd9893..e56c057 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3241,7 +3241,8 @@ Log.WriteLine("DDD");
}
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP, currentJump.UniqueID);
+ if (! Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP, currentJump.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
if(weightPercentPreferred)
myTreeViewJumps.Add(currentPerson.Name, currentJump);
@@ -3368,7 +3369,8 @@ Log.WriteLine("DDD 2");
currentJumpRj = (JumpRj) currentEventExecute.EventDone;
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, currentJumpRj.UniqueID);
+ if(! Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, currentJumpRj.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
//if user clicked in finish earlier
if(currentEventExecute.Finish) {
@@ -3522,7 +3524,8 @@ Log.WriteLine("DDD 2");
currentRun = (Run) currentEventExecute.EventDone;
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN, currentRun.UniqueID);
+ if(! Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN, currentRun.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
currentRun.MetersSecondsPreferred = metersSecondsPreferred;
@@ -3647,7 +3650,8 @@ Log.WriteLine("DDD 2");
currentRunInterval = (RunInterval) currentEventExecute.EventDone;
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, currentRunInterval.UniqueID);
+ if(! Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, currentRunInterval.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
currentRunInterval.MetersSecondsPreferred = metersSecondsPreferred;
@@ -3759,7 +3763,8 @@ Log.WriteLine("DDD 2");
currentReactionTime = (ReactionTime) currentEventExecute.EventDone;
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RT, currentReactionTime.UniqueID);
+ if(! Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RT, currentReactionTime.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
myTreeViewReactionTimes.Add(currentPerson.Name, currentReactionTime);
@@ -3877,7 +3882,8 @@ Log.WriteLine("DDD 2");
currentPulse = (Pulse) currentEventExecute.EventDone;
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, currentPulse.UniqueID);
+ if(! Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, currentPulse.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
myTreeViewPulses.Add(currentPerson.Name, currentPulse);
@@ -4120,8 +4126,9 @@ Console.WriteLine("V");
currentMultiChronopic = (MultiChronopic) currentEventExecute.EventDone;
Console.WriteLine("W");
//move video file if exists
- Util.MoveTempVideo(currentSession.UniqueID,
- Constants.TestTypes.MULTICHRONOPIC, currentMultiChronopic.UniqueID);
+ if(! Util.MoveTempVideo(currentSession.UniqueID,
+ Constants.TestTypes.MULTICHRONOPIC, currentMultiChronopic.UniqueID))
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored."));
//this produces also a crash:
//new DialogMessage(Constants.MessageTypes.INFO, "Please, touch a platform now.");
diff --git a/src/util.cs b/src/util.cs
index 6f14b81..3640ca9 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -797,15 +797,19 @@ public class Util
return Constants.ExtensionPhoto;
}
- public static void MoveTempVideo(int sessionID, Constants.TestTypes type, int uniqueID) {
- if(File.Exists(GetVideoTempFileName())) {
+ public static bool MoveTempVideo(int sessionID, Constants.TestTypes type, int uniqueID) {
+ string origin = GetVideoTempFileName();
+ string destination = GetVideoFileName(sessionID, type, uniqueID);
+ if(File.Exists(origin) && ! File.Exists(destination)) {
CreateVideoSessionDirIfNeeded(sessionID);
try {
- File.Move(GetVideoTempFileName(), GetVideoFileName(sessionID, type, uniqueID));
+ File.Move(origin, destination);
} catch {
- File.Copy(GetVideoTempFileName(), GetVideoFileName(sessionID, type, uniqueID));
+ File.Copy(origin, destination);
}
- }
+ return true;
+ } else
+ return false;
}
public static void DeleteVideo(int sessionID, Constants.TestTypes type, int uniqueID) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]