~psycotica0/sgx-dummy

44ca896f9afde6df4811a783bf1249b0d0be3fc6 — Christopher Vollick 10 months ago fcab5a5 cv_adhoc_test_command
Rename Config to Configt, Add More Fields

The adhoc bot I was testing does prefixing, so
configure-direct-blahblahblah was making it so my command never actually
ran.

Also I wanted to test more types
1 files changed, 43 insertions(+), 11 deletions(-)

M gateway.lhs
M gateway.lhs => gateway.lhs +43 -11
@@ 116,7 116,7 @@ Command List
> 			XML.Element (s"{http://jabber.org/protocol/disco#items}query") [(s"node", [s"http://jabber.org/protocol/commands"])] [
> 				XML.NodeElement $ XML.Element (s"item") [
> 					(s"jid", [XML.ContentText $ XMPP.formatJID to]),
> 					(s"node", [s"config"]),
> 					(s"node", [s"configt"]),
> 					(s"name", [s"Test Form"])
> 				] []
> 			]


@@ 128,7 128,7 @@ Command Final Page
> 	XMPP.iqTo = Just XMPP.JID { XMPP.jidNode = Nothing },
> 	XMPP.iqPayload = Just p
> })
> 	| [command] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"config" ==) =<< XML.hasAttributeText (s"action") (s"execute" ==) p,
> 	| [command] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"configt" ==) =<< XML.hasAttributeText (s"action") (s"execute" ==) p,
> 	  [_] <- XML.hasAttributeText (s"var") (s"runlevel" ==) =<< XML.isNamed(s"{jabber:x:data}field") =<< XML.elementChildren =<< XML.isNamed(s"{jabber:x:data}x") =<< XML.elementChildren command
> 		= XMPP.putStanza $ iqReply iq $ Just $ XML.documentRoot page3



@@ 139,7 139,7 @@ And the same if they use "complete" instead of "execute"
> 	XMPP.iqTo = Just XMPP.JID { XMPP.jidNode = Nothing },
> 	XMPP.iqPayload = Just p
> })
> 	| [command] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"config" ==) =<< XML.hasAttributeText (s"action") (s"complete" ==) p,
> 	| [command] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"configt" ==) =<< XML.hasAttributeText (s"action") (s"complete" ==) p,
> 	  [_] <- XML.hasAttributeText (s"var") (s"runlevel" ==) =<< XML.isNamed(s"{jabber:x:data}field") =<< XML.elementChildren =<< XML.isNamed(s"{jabber:x:data}x") =<< XML.elementChildren command
> 		= XMPP.putStanza $ iqReply iq $ Just $ XML.documentRoot page3



@@ 150,7 150,7 @@ Command Page 2
> 	XMPP.iqTo = Just XMPP.JID { XMPP.jidNode = Nothing },
> 	XMPP.iqPayload = Just p
> })
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"config" ==) =<< XML.hasAttributeText (s"action") (s"next" ==) p
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"configt" ==) =<< XML.hasAttributeText (s"action") (s"next" ==) p
> 		= XMPP.putStanza $ iqReply iq $ Just $ XML.documentRoot page2

Command Page 1


@@ 160,7 160,7 @@ Command Page 1
> 	XMPP.iqTo = Just XMPP.JID { XMPP.jidNode = Nothing },
> 	XMPP.iqPayload = Just p
> })
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"config" ==) =<< XML.hasAttributeText (s"action") (s"execute" ==) p
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"configt" ==) =<< XML.hasAttributeText (s"action") (s"execute" ==) p
> 		= XMPP.putStanza $ iqReply iq $ Just $ XML.documentRoot page1

And again, handling "previous"


@@ 170,7 170,7 @@ And again, handling "previous"
> 	XMPP.iqTo = Just XMPP.JID { XMPP.jidNode = Nothing },
> 	XMPP.iqPayload = Just p
> })
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"config" ==) =<< XML.hasAttributeText (s"action") (s"prev" ==) p
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"configt" ==) =<< XML.hasAttributeText (s"action") (s"prev" ==) p
> 		= XMPP.putStanza $ iqReply iq $ Just $ XML.documentRoot page1

One more time, this time with no action...


@@ 180,7 180,7 @@ One more time, this time with no action...
> 	XMPP.iqTo = Just XMPP.JID { XMPP.jidNode = Nothing },
> 	XMPP.iqPayload = Just p
> })
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"config" ==) p
> 	| [_] <- XML.isNamed (s"{http://jabber.org/protocol/commands}command") =<< XML.hasAttributeText (s"node") (s"configt" ==) p
> 		= XMPP.putStanza $ iqReply iq $ Just $ XML.documentRoot page1

Any other IQ we don't bother with, but should return an error so nothing gets stuck.


@@ 297,7 297,7 @@ These pages pulled from https://xmpp.org/extensions/xep-0050.html
> page1 = XML.parseText_ XML.def $ s"\
>\		  <command xmlns='http://jabber.org/protocol/commands'\
>\		           sessionid='config:20020923T213616Z-700'\
>\		           node='config'\
>\		           node='configt'\
>\		           status='executing'>\
>\		    <actions execute='next'>\
>\		      <next/>\


@@ 318,7 318,7 @@ These pages pulled from https://xmpp.org/extensions/xep-0050.html
> page2 = XML.parseText_ XML.def $ s"\
>\	  <command xmlns='http://jabber.org/protocol/commands'\
>\	           sessionid='config:20020923T213616Z-700'\
>\	           node='config'\
>\	           node='configt'\
>\	           status='executing'>\
>\	    <actions execute='complete'>\
>\	      <prev/>\


@@ 338,17 338,49 @@ These pages pulled from https://xmpp.org/extensions/xep-0050.html
>\	        <option label='X-Window'><value>5</value></option>\
>\	      </field>\
>\	      <field var='state' label='Run State' type='list-single'>\
>\	        <desc>Which state should this run in?</desc>\
>\	        <value>off</value>\
>\	        <option label='Active'><value>off</value></option>\
>\	        <option label='Active&quot;n Shit'><value>off</value></option>\
>\	        <option label='Inactive'><value>on</value></option>\
>\	      </field>\
>\	      <field var='boo1' label='Is enabled' type='boolean'>\
>\	        <value>1</value>\
>\	      </field>\
>\	      <field var='boo2' label='Is not enabled' type='boolean'>\
>\	        <desc>Shouldn't it not not be disabled</desc>\
>\	        <value>false</value>\
>\	      </field>\
>\	      <field type='fixed'>\
>\	        <value>Ok...</value>\
>\	        <value>Now let's go wild &amp; party</value>\
>\	        <value>Now let&apos;s go wild &amp; party</value>\
>\	      </field>\
>\	      <field var='hiddenVar' label='Some text' type='hidden' >\
>\	        <value>hidden value</value>\
>\	      </field>\
>\	      <field var='text' label='Some text' type='text-single' />\
>\	      <field label='What&apos;s this!' type='text-single' />\
>\	      <field var='text2' label='Somethin&apos; default' >\
>\	        <value>It's wonderful!</value>\
>\	      </field>\
>\	      <field var='text2' label='Something unknown' type='moop' >\
>\	        <desc>What is moop?</desc>\
>\	      </field>\
>\	      <field var='text2' label='Some text' type='text-single' >\
>\	        <desc>What is the answer to all life</desc>\
>\	        <value>awesome truth</value>\
>\	      </field>\
>\	      <field type='fixed'>\
>\	        <value>Try JID</value>\
>\	      </field>\
>\	      <field var='testjid' label='Best friend' type='jid-single' />\
>\	    </x>\
>\	  </command>"

> page3 = XML.parseText_ XML.def $ s"\
>\  <command xmlns='http://jabber.org/protocol/commands'\
>\           sessionid='config:20020923T213616Z-700'\
>\           node='config'\
>\           node='configt'\
>\           status='completed'>\
>\    <note type='info'>Service 'httpd' has been configured.</note>\
>\  </command>"