From bc64e2e7537d714b67697cced7215ff819b0a23e Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Mon, 25 Apr 2011 18:21:25 +0100
Subject: No Ad-Hoc buttons once command is completed


diff --git a/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp b/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
index edacf94..da7f042 100644
--- a/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
+++ b/Swiften/AdHoc/OutgoingAdHocCommandSession.cpp
@@ -21,22 +21,24 @@ void OutgoingAdHocCommandSession::handleResponse(boost::shared_ptr<Command> payl
 	} else {
 		const std::vector<Command::Action> actions = payload->getAvailableActions();
 		actionStates_.clear();
-		actionStates_[Command::Cancel] = EnabledAndPresent;
-		actionStates_[Command::Complete] = Present;
-		if (std::find(actions.begin(), actions.end(), Command::Complete) != actions.end()) {
-			actionStates_[Command::Complete] = EnabledAndPresent;
-		}
-
-		if (getIsMultiStage()) {
-			actionStates_[Command::Next] = Present;
-			actionStates_[Command::Prev] = Present;
-		}
+		if (payload->getStatus() == Command::Executing ) {
+			actionStates_[Command::Cancel] = EnabledAndPresent;
+			actionStates_[Command::Complete] = Present;
+			if (std::find(actions.begin(), actions.end(), Command::Complete) != actions.end()) {
+				actionStates_[Command::Complete] = EnabledAndPresent;
+			}
+
+			if (getIsMultiStage()) {
+				actionStates_[Command::Next] = Present;
+				actionStates_[Command::Prev] = Present;
+			}
 
 		if (std::find(actions.begin(), actions.end(), Command::Next) != actions.end()) {
-			actionStates_[Command::Next] = EnabledAndPresent;
-		}
+				actionStates_[Command::Next] = EnabledAndPresent;
+			}
 		if (std::find(actions.begin(), actions.end(), Command::Prev) != actions.end()) {
-			actionStates_[Command::Prev] = EnabledAndPresent;
+				actionStates_[Command::Prev] = EnabledAndPresent;
+			}
 		}
 
 		sessionID_ = payload->getSessionID();
diff --git a/Swiften/AdHoc/OutgoingAdHocCommandSession.h b/Swiften/AdHoc/OutgoingAdHocCommandSession.h
index fcc93e7..f4b5242 100644
--- a/Swiften/AdHoc/OutgoingAdHocCommandSession.h
+++ b/Swiften/AdHoc/OutgoingAdHocCommandSession.h
@@ -73,6 +73,7 @@ namespace Swift {
 			 * This is useful for a UI to determine which buttons should be visible,
 			 * and which enabled.
 			 * Use for Next, Prev, Cancel and Complete only.
+			 * If no actions are available, the command has completed.
 			 */
 			ActionState getActionState(Command::Action action);
 		private:
-- 
cgit v0.10.2-6-g49f6