Make the status notifcation cmd optional. Also make the status parameter optional
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 29 Apr 2011 09:30:29 +0000 (11:30 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 29 Apr 2011 09:30:29 +0000 (11:30 +0200)
src/link/linkstatusanalyzer.cpp
src/link/statusnotifiercommand.cpp

index 30e7b34..b85d77a 100644 (file)
@@ -30,7 +30,6 @@ LinkStatusAnalyzer::LinkStatusAnalyzer(
 {
     BOOST_ASSERT( 0 <= hosts_down_limit );
     BOOST_ASSERT( 0 <= link_up_interval_in_min );
-    BOOST_ASSERT( !status_notifier_cmd.empty() );
 }
 
 LinkStatusAnalyzer::~LinkStatusAnalyzer()
@@ -104,14 +103,14 @@ void LinkStatusAnalyzer::notify_link_up()
         BOOST_ASSERT( CurrentLinkStatus == LinkStatus_Up );
         BOOST_ASSERT( CurrentNotificationStatus == NotificationStatus_NotReported );
 
-        bool replaced = StatusNotifierCmd.set_token_value(
+        StatusNotifierCmd.set_token_value(
                 StatusNotifierCommand::StatusToken,
                 "up"
-        );
+        );                                                                          //lint !e534
 
         bool executed = StatusNotifierCmd.execute();
 
-        if ( replaced && executed )
+        if ( executed )
         {
             CurrentNotificationStatus = NotificationStatus_Reported;
         }
@@ -127,14 +126,14 @@ void LinkStatusAnalyzer::notify_link_down()
         BOOST_ASSERT( CurrentLinkStatus == LinkStatus_Down );
         BOOST_ASSERT( CurrentNotificationStatus == NotificationStatus_NotReported );
 
-        bool replaced = StatusNotifierCmd.set_token_value(
+        StatusNotifierCmd.set_token_value(
                 StatusNotifierCommand::StatusToken,
                 "down"
-        );
+        );                                                                              //lint !e534
 
         bool executed = StatusNotifierCmd.execute();
 
-        if ( replaced && executed )
+        if ( executed )
         {
             CurrentNotificationStatus = NotificationStatus_Reported;
         }
index e894ff6..f652cd0 100644 (file)
@@ -38,7 +38,6 @@ bool StatusNotifierCommand::set_token_value(
 {
     BOOST_ASSERT( !token.empty() );
     BOOST_ASSERT( !value.empty() );
-    BOOST_ASSERT( !CommandStr.empty() );
 
     const size_t token_begin_pos = CommandStr.find( token );
     if ( token_begin_pos == string::npos )
@@ -57,7 +56,9 @@ bool StatusNotifierCommand::set_token_value(
 
 bool StatusNotifierCommand::execute() const
 {
-    BOOST_ASSERT( !CommandStr.empty() );
+    // Check if users wants notification at all
+    if (CommandStr.empty())
+        return true;
 
     string app = get_application_string();
     string args = get_arguments_string();