#include <adhoc.h>
Inherits DiscoNodeHandler, DiscoHandler, and IqHandler.
Inheritance diagram for Adhoc:

Public Member Functions | |
| Adhoc (ClientBase *parent) | |
| virtual | ~Adhoc () |
| void | checkSupport (const JID &remote, AdhocHandler *ah) |
| void | getCommands (const JID &remote, AdhocHandler *ah) |
| void | execute (const JID &remote, const Adhoc::Command *command, AdhocHandler *ah) |
| void | respond (const JID &remote, const Adhoc::Command *command, const Error *error=0) |
| void | registerAdhocCommandProvider (AdhocCommandProvider *acp, const std::string &command, const std::string &name) |
| void | removeAdhocCommandProvider (const std::string &command) |
| virtual StringList | handleDiscoNodeFeatures (const JID &from, const std::string &node) |
| virtual Disco::IdentityList | handleDiscoNodeIdentities (const JID &from, const std::string &node) |
| virtual Disco::ItemList | handleDiscoNodeItems (const JID &from, const JID &to, const std::string &node) |
| virtual bool | handleIq (const IQ &iq) |
| virtual void | handleIqID (const IQ &iq, int context) |
| virtual void | handleDiscoInfo (const JID &from, const Disco::Info &info, int context) |
| virtual void | handleDiscoItems (const JID &from, const Disco::Items &items, int context) |
| virtual void | handleDiscoError (const JID &from, const Error *error, int context) |
Classes | |
| class | Command |
| An abstraction of an Adhoc Command element (from Adhoc Commands, XEP-0050) as a StanzaExtension. More... | |
The current, not complete, implementation is probably best suited for fire-and-forget type of commands. Any additional feature, like multiple stages, etc., would have to be added separately.
To offer commands to remote entities, use this class as follows:
Create a class that will handle command execution requests and derive it from AdhocCommandProvider. Instantiate an Adhoc object and register your AdhocCommandProvider-derived object with the Adhoc object using registerAdhocCommandProvider(). The additional parameters to that method are the internal name of the command as used in the code, and the public name of the command as it will be shown to an end user:
MyClass::someFunc()
{
Adhoc* m_adhoc = new Adhoc( m_client );
// this might be a bot monitoring a weather station, for example
m_adhoc->registerAdhocCommandProvider( this, "getTemp", "Retrieve current temperature" );
m_adhoc->registerAdhocCommandProvider( this, "getPressure", "Retrieve current air pressure" );
[...]
}
And that's about it you can do with the Adhoc class. Of course you can have a AdhocCommandProvider handle more than one command, just register it with the Adhoc object for every desired command, like shown above.
What the Adhoc object does when you install a new command is tell the supplied Disco object to advertise these commands to clients using the 'Service Discovery' protocol to learn about this implementation's features. These clients can then call and execute the command. Of course you are free to implement access restrictions to not let anyone mess with your bot, for example. However, the commands offered using Service Discovery are publically visible in any case.
To execute commands offered by a remote entity:
...TBC...
XEP version: 1.2
Definition at line 80 of file adhoc.h.
|
|
Constructor. Creates a new Adhoc client that registers as IqHandler with a ClientBase.
|
|
|
Virtual destructor. |
|
||||||||||||
|
This function queries the given remote entity for Adhoc Commands support.
|
|
||||||||||||||||
|
Executes or continues the given command on the given remote entity. To construct the
|
|
||||||||||||
|
Retrieves a list of commands from the remote entity. You should check whether the remote entity actually supports Adhoc Commands by means of checkSupport().
|
|
||||||||||||||||
|
Reimplement this function to receive disco error notifications.
Implements DiscoHandler. |
|
||||||||||||||||
|
Reimplement this function if you want to be notified about the result of an disco#info query.
Implements DiscoHandler. |
|
||||||||||||||||
|
Reimplement this function if you want to be notified about the result of a disco#items query.
Implements DiscoHandler. |
|
||||||||||||
|
In addition to
Implements DiscoNodeHandler. |
|
||||||||||||
|
In addition to
Implements DiscoNodeHandler. |
|
||||||||||||||||
|
This function is used to gather more information on a specific node. It is called when a disco#items query arrives with a node attribute that matches the one registered for this handler. If node is empty, items for the root node (no node) shall be returned.
Implements DiscoNodeHandler. |
|
|
Reimplement this function if you want to be notified about incoming IQs.
Implements IqHandler. |
|
||||||||||||
|
Reimplement this function if you want to be notified about incoming IQs with a specific value of the
Implements IqHandler. |
|
||||||||||||||||
|
Using this function, you can register a AdhocCommandProvider -derived object as handler for a specific Ad-hoc Command as defined in XEP-0050.
|
|
|
Use this function to unregister an adhoc command previously registered using registerAdhocCommandProvider().
|
|
||||||||||||||||
|
Use this function to respond to an execution request submitted by means of AdhocCommandProvider::handleAdhocCommand(). It is recommended to use Command( const std::string&, const std::string&, Status, DataForm* ) to construct the |
1.4.1