/* */
parse arg eMail Password

Data = ""
Error = ""
Status = ""
AccountKey = ""

select
      when eMail = "update" then
           do
             '@boinc_cmd.exe --project http://setiathome.berkeley.edu update'
             exit
           end
      when eMail = "detach" then
           do
           '@boinc_cmd.exe --project http://setiathome.berkeley.edu detach'
             exit
           end
      when eMail = "suspend" then
           do
           '@boinc_cmd.exe --project http://setiathome.berkeley.edu suspend'
             exit
           end
      when eMail = "resume" then
           do
           '@boinc_cmd.exe --project http://setiathome.berkeley.edu resume'
             exit
           end
      otherwise
               do
if eMail = "" then
   do
     say "Project http://setiathome.berkeley.edu:"
     say ""
     say "Options:"
     say "setiathome.cmd <Username> <Password> for project attach"
     say "setiathome.cmd update for project update"
     say "setiathome.cmd detach for project detach"
     say "setiathome.cmd suspend for project suspending"
     say "setiathome.cmd resume for project resuming"
     exit
   end
if Password = "" then
   do
     say "Project http://setiathome.berkeley.edu:"
     say ""
     say "Options:"
     say "setiathome.cmd <Username> <Password> for project attach"
     say "setiathome.cmd update for project update"
     say "setiathome.cmd detach for project detach"
     say "setiathome.cmd suspend for project suspending"
     say "setiathome.cmd resume for project resuming"
     exit
   end
               end
end

'@boinc_cmd.exe --lookup_account http://setiathome.berkeley.edu ' || eMail || ' ' || Password || ' | RXQUEUE'
do queued()
    Data = linein("QUEUE:")
    Status = substr(Data,1,12)
    if Status = "account key:" then
       do
         AccountKey = substr(Data,13)
         '@boinc_cmd.exe --project_attach http://setiathome.berkeley.edu ' ||  AccountKey
       end
       else
           Error = Data
end

if Status = "account key:" then
   do
     say "Project http://setiathome.berkeley.edu:"
     say ""
     say "successfull attach to project http://setiathome.berkeley.edu!"
     say "account key is: " || AccountKey
     say "now copying OS/2 application into project directory..."
     '@copy setiathome-6.10.i386-pc-os2-emx.exe projects\setiathome.berkeley.edu'
     '@copy astropulse-4.28.i386-pc-os2-emx.exe projects\setiathome.berkeley.edu'
     '@copy ..\setiathome_app_info.xml projects\setiathome.berkeley.edu\app_info.xml'
     say "Remember to change all occurence of <min_rpc_time> to 0.00 in client_state.xml"
     say "for immediate download of WorkUnit."
  end
  else
      do
        say "Project http://setiathome.berkeley.edu:"
        say ""
        say "Unable to attach..."
        say "error: " || Error
        exit
      end
