 
/* Common Var */


typeof msgBuffer= S;;

proto refreshTextArea= fun [S S] I;;

/* DEFCOMs */

/* request msg to Server, given it's ID */
defcom CsendMsg = CsendMsg S S;;

/* Sends */
defcom CpostMsg= CpostMsg S S S;;

defcom CreplyToMsg= CreplyToMsg S S S S;;

/*---- Client Requests ---------------------------*/



/* Get the News Group List */
fun requestNgList()=
  _RSCdownload this getServerNGListFilename getServerNGListFilename nil 1;
  0;;



/* Download all Subscribed News Groups Header */
fun dlHeader(nodeList)=
  if nodeList==nil
  then 0
  else
  let nodeList -> [firstNode next] in
  let strcatn ("NG"::firstNode.id::newsServerIP::".sng"::nil) -> headerName in
  let getHeaderFilename firstNode.id -> headerFile in
   (_showconsole; _fooS "_________||_________headerName"; _fooS headerName;
    _fooS "_________||_________headerFile"; _fooS headerFile;
    _RSCdownload this headerName headerFile nil 1;
    dlHeader next;
    0
   );;


/* The file containing the NG list must have been DL first */
fun requestSubsNGHeaders()=
  dlHeader getTreeFromFile getServerNGListFilename;;


/* Request *One* NG Header */
fun requestNgHeader(ngResName, fileName)=
  _RSCdownload this ngResName fileName nil 1;;



/* Request a specific message knowing its ID */
fun requestMessage(NGID, headerID)=
  _DMSsend this CsendMsg [NGID headerID];;


/* COM activated by server to display the requested msg */
fun __CreceiveMsg(NGID, msgID, msg)=
  saveMsg msgID strtoweb msg getMsgFilename NGID;
  refreshTextArea msgID msg;;



fun requestNGList()=
  requestNgList;
  getTreeFromFile getServerNGListFilename;;


/* Synchronize by requesting all the headers of the subscribed NG */
fun synchronize()=
  requestNGList;
  requestSubsNGHeaders
;;
