/** * * Copyright 2005-2007 Jive Software. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jivesoftware.smackx.commands; import org.jivesoftware.smackx.commands.packet.AdHocCommandData; import org.jxmpp.jid.Jid; /** * Represents a command that can be executed locally from a remote location. This * class must be extended to implement an specific ad-hoc command. This class * provides some useful tools:
true
.
*
* @return true if the command is in the last stage.
*/
public abstract boolean isLastStage();
/**
* Returns true if the specified requester has permission to execute all the
* stages of this action. This is checked when the first request is received,
* if the permission is grant then the requester will be able to execute
* all the stages of the command. It is not checked again during the
* execution.
*
* @param jid the JID to check permissions on.
* @return true if the user has permission to execute this action.
*/
public abstract boolean hasPermission(Jid jid);
/**
* Returns the currently executing stage number. The first stage number is
* 0. During the execution of the first action this method will answer 0.
*
* @return the current stage number.
*/
public int getCurrentStage() {
return currentStage;
}
@Override
void setData(AdHocCommandData data) {
data.setSessionID(sessionID);
super.setData(data);
}
/**
* Increase the current stage number. This is automatically handled and should
* not be called.
*
*/
void incrementStage() {
currentStage++;
}
/**
* Decrease the current stage number. This is automatically handled and should
* not be called.
*
*/
void decrementStage() {
currentStage--;
}
}