/* 
Example Jabberwocky ARexx Script
$VER: Example.jrx 1.0 (24.02.2003)
By J.E. Gilpin

This script demonstrates the use of some Jabberwocky ARexx commands.
Jabberwocky must already be running and your computer must be online
before this script is executed.
You can use it to save a copy of your account and roster information.
Open a shell, make Jabberwocky the current directory (CD Jabberwocky)
and enter "rx >Roster.txt Rexx/Example.jrx" on the command line.
Your account information will be saved to the file "Roster.txt".
*/
OPTIONS RESULTS

jabber_port="JABBERWOCKY.1"

IF ~SHOW("PORT", jabber_port) THEN DO
  SAY "Jaberwocky not found."
  EXIT 5
END

ADDRESS JABBERWOCKY.1
ISONLINE
Online = RC
IF ~Online THEN DO
  CONNECT
  DO loop = 1 TO 10
    ISONLINE
    Online=RC
    IF Online THEN DO
      SAY "Online"
      LEAVE
    END
  ELSE SAY "Waiting"
  ADDRESS COMMAND 'Wait 1'
  END
  ADDRESS COMMAND 'Wait 2'
END

IF ~Online THEN DO
  SAY "Jabberwocky not responding"
  EXIT 5
END

GETUSER STEM UserInfo
SAY "User JabberID =" UserInfo.USER||"@"||UserInfo.SERVER||"/"||UserInfo.RESOURCE

IF OPEN(Account,"Account.xml",'R') THEN DO
  line=READLN(Account)
  CALL CLOSE(Account)
  PARSE VAR line "password>" Password "<" temp
  SAY "Password = "Password
END

Jabber. = 0
GETROSTER STEM Jabber
Number = Jabber.COUNT
If Number = 0 THEN DO
  SAY "No contacts in roster."
  EXIT 0
END
SAY "Roster entries =" Number

DO loop = 0 TO Number-1
  IF Jabber.loop.USER = 0 THEN SAY "Transport=" Jabber.loop.SERVER
  ELSE SAY "JabberID" "=" Jabber.loop.USER||"@"||Jabber.loop.SERVER
END

EXIT 0
