From 251ea3b060a81724779189df9bb9f7aa5741b177 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 13 Mar 2018 11:58:44 -0600 Subject: [PATCH] Tweaks for issue #125 --- GBM/Forms/frmMain.vb | 78 ++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 73aebfb..8bd9e7c 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1267,11 +1267,51 @@ Public Class frmMain End If End Sub - Public Sub UpdateLog(sLogUpdate As String, Optional bTrayUpdate As Boolean = True, Optional objIcon As System.Windows.Forms.ToolTipIcon = ToolTipIcon.Info, Optional bTimeStamp As Boolean = True) Handles oBackup.UpdateLog, oRestore.UpdateLog + Private Function NotifySendUnix(ByVal sLogUpdate As String, ByVal objIcon As System.Windows.Forms.ToolTipIcon) As Boolean Dim prsNotify As Process - Dim bNotifyFailed As Boolean Dim sUrgency As String Dim sNotifyArgs As String + Dim bNotifyFailed As Boolean + + 'Build args for notify-send + Select Case objIcon + Case ToolTipIcon.Error + sUrgency = "critical" + Case ToolTipIcon.Warning + sUrgency = "normal" + Case ToolTipIcon.Info + sUrgency = "low" + Case Else + sUrgency = "low" + End Select + + sNotifyArgs = "-i gbm " & "-u " & sUrgency & " """ & App_NameLong & """ """ & sLogUpdate.Replace("""", "\""") & """" + + Try + 'Execute notify-send + prsNotify = New Process + prsNotify.StartInfo.FileName = "/usr/bin/notify-send" + prsNotify.StartInfo.Arguments = sNotifyArgs + prsNotify.StartInfo.UseShellExecute = False + prsNotify.StartInfo.RedirectStandardOutput = True + prsNotify.StartInfo.CreateNoWindow = True + prsNotify.Start() + prsNotify.WaitForExit() + Select Case prsNotify.ExitCode + Case 0 + bNotifyFailed = False + Case Else + bNotifyFailed = True + End Select + Catch + bNotifyFailed = True + End Try + + Return bNotifyFailed + End Function + + Public Sub UpdateLog(sLogUpdate As String, Optional bTrayUpdate As Boolean = True, Optional objIcon As System.Windows.Forms.ToolTipIcon = ToolTipIcon.Info, Optional bTimeStamp As Boolean = True) Handles oBackup.UpdateLog, oRestore.UpdateLog + Dim bNotifyFailed As Boolean 'Thread Safe (If one control requires an invoke assume they all do) If txtLog.InvokeRequired = True Then @@ -1311,39 +1351,7 @@ Public Class frmMain If bTrayUpdate Then If mgrCommon.IsUnix Then - 'Build args for notify-send - Select Case objIcon - Case ToolTipIcon.Error - sUrgency = "critical" - Case ToolTipIcon.Warning - sUrgency = "normal" - Case ToolTipIcon.Info - sUrgency = "low" - Case Else - sUrgency = "low" - End Select - - sNotifyArgs = "-i gbm " & "-u " & sUrgency & " """ & App_NameLong & """ """ & sLogUpdate.Replace("""", "\""") & """" - - Try - 'Execute notify-send - prsNotify = New Process - prsNotify.StartInfo.FileName = "/usr/bin/notify-send" - prsNotify.StartInfo.Arguments = sNotifyArgs - prsNotify.StartInfo.UseShellExecute = False - prsNotify.StartInfo.RedirectStandardOutput = True - prsNotify.StartInfo.CreateNoWindow = True - prsNotify.Start() - prsNotify.WaitForExit() - Select Case prsNotify.ExitCode - Case 0 - bNotifyFailed = False - Case Else - bNotifyFailed = True - End Select - Catch - bNotifyFailed = True - End Try + bNotifyFailed = NotifySendUnix(sLogUpdate, objIcon) End If If Not mgrCommon.IsUnix Or bNotifyFailed Then