home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / VirtualA / 32bit / vasetup.exe / %MYDIR% / NEWSNET.EBS < prev    next >
Encoding:
Text File  |  1999-10-06  |  5.3 KB  |  180 lines

  1. 'T:NEWSNET.EBS for CIX
  2. ' VA 4.52 release
  3.  
  4. 'Add file to import queue
  5. Declare Function AddToDoList16 Pascal Lib "addons.dll" Alias "AddToDoList" (ByVal szService As String, ByVal szFileName As String, ByVal szMailname As String, ByVal iFlags As Long) As Integer
  6. Declare Function AddToDoList32 Pascal Lib "addons32.dll" Alias "AddToDoList" (ByVal szService As String, ByVal szFileName As String, ByVal szMailname As String, ByVal iFlags As Long) As Long
  7.  
  8. 'T:iFlags for CIX (constant)
  9. Global Const IM_DELETE = 2048        ' Delete scratchpad file afterwards? 
  10.  
  11. Declare Function GotoAreaOk(id As String, serv As String)
  12. Declare Function UniqueFileName$
  13. Declare Function QueueFile(service As String, sfilename As String, _
  14.                            queueflags As Long) As Boolean
  15. Declare Sub ReportSuccess(id As String)
  16. Declare Sub ReportFailure(id As String, reason As String)
  17.  
  18. 'T:NewsCont (subroutine) (CIX)
  19. Sub NewsCont(t As Tracker)
  20.     Comms.Send "n\r"
  21.     WaitForPrompt "Prompt"
  22.     Comms.Send "end\r"
  23.     WaitForPrompt "Prompt"
  24.     t.reset
  25. End Sub
  26.  
  27. 'T:DownNewsnet (subroutine) (CIX)
  28. Sub DownNewsnet(id As String)
  29.     Dim t As Tracker
  30.     Dim ResOK As Tracker
  31.     Dim ResErr As Tracker
  32.  
  33.     Terminal.Status "Going into Usenet"
  34.     If Not GotoAreaOk(id, "Newsnet") Then
  35.         Exit Sub
  36.     End If
  37.     Terminal.Status ""
  38.  
  39.     Comms.Send "echo Newsnet scratchpad\r"
  40.     WaitForPrompt "Prompt"
  41.     Set t = CreateTracker("NewsContinue", "Continue\? (Y/N)", "NewsCont")
  42.     Comms.Send "batch all endbatch\r"
  43.     Terminal.Status "Collecting messages from usenet"
  44.     TimedWaitForPrompt "Prompt", 180 ' 3 minutes
  45.     t.delete
  46.     Terminal.Status ""
  47.     Comms.Send "download messages\r"
  48.  
  49.     Set ResErr = CreateTracker("Result200", "Result 200:")
  50.     Set ResOk = CreateTracker("ResultOK", "\*\*")
  51.     WaitFor "\*\*"
  52.     DeleteFile "cixnews.msg"
  53.     FileDownload PROT_ZMODEM, "cixnews.msg"
  54.     WaitFor "Newsnet:"
  55.     ResErr.delete
  56.     ResOK.delete
  57.     If QueueFile(Session.Service, "cixnews.msg", IM_DELETE)=True Then
  58.             ReportSuccess id & " : Collected Newsnet messages"
  59.             SetLastUpdated "Read messages from Newsgroups"
  60.     Else
  61.             ReportFailure id, "Empty newsnet scratchpad or download failure"
  62.     End If
  63. End Sub
  64.  
  65. 'T:CopyUsenetMessageToFile (subroutine) (CIX)
  66. 'Copy a message file to the CIXNEWS script
  67. 'Terminate with a line containing just "."
  68. Sub CopyUsenetMessageToFile(filename As String)
  69.     Dim inpline As String
  70.  
  71.     On Error Goto CopyMessageToFile_error
  72.     Open filename For Input Access Read Shared As #1
  73.     While Not Eof(1)
  74.         Line Input #1, inpline
  75.         If inpline <> "." Then
  76.             Print #6, inpline
  77.         End If
  78.     Wend
  79. CopyMessageToFile_nofile:
  80.     On Error Goto 0
  81.     Close #1
  82.     Exit Sub
  83. CopyMessageToFile_error:
  84.     Resume CopyMessageToFile_nofile
  85. End Sub
  86.  
  87. 'T:PostNewsnet (subroutine) (CIX)
  88. ' Post message to newsnet - can be either a say/comment
  89. Sub PostNewsnet(id As String, newsgroup As String, subject As String, filename As String)
  90.     Dim messagescript As String
  91.     Dim messagetmp As String
  92.  
  93.     Terminal.Status "Going into Usenet"
  94.     If Not GotoAreaOk(id, "Newsnet") Then
  95.         Exit Sub
  96.     End If
  97.     Terminal.Status ""
  98.  
  99.     messagetmp = Session.ServicePath + "cixnews.tmp"
  100.     DeleteFile messagetmp
  101.     Open messagetmp For Output Access Write Shared As #6
  102.  
  103.     Print #6, "Newsgroups: " + newsgroup
  104.     If subject<>"" Then
  105.         Print #6, "Subject: " + subject
  106.     End If
  107.     Print #6, "X-Newsreader: Virtual Access"
  108.     If subject="" Then
  109.         Print #6, "Subject: ";
  110.     Else
  111.         Print #6,
  112.     End If
  113.     CopyUsenetMessageToFile filename
  114.     Close #6
  115.  
  116.     'Find out length of msg and do the #! Rnews line
  117.     messagescript = Session.ServicePath + "cixnews.upl"
  118.     DeleteFile messagescript
  119.     Open messagescript For Output Access Write Shared As #6
  120.     Print #6, "#! rnews " & (FileLen(messagetmp)-1)
  121.     CopyUsenetMessageToFile messagetmp
  122.     Print #6, "."
  123.     Close #6
  124.  
  125.     Comms.Send "upload messages\r"
  126.     WaitFor "\*\*"
  127.     FileUpload PROT_ZMODEM, messagescript
  128.     WaitFor ":"
  129.  
  130.     ReportSuccess id & " : Posted Newsnet message to " & newsgroup
  131. End Sub
  132.  
  133. 'T:JoinNewsgroup (subroutine) (CIX)
  134. Sub JoinNewsgroup(id As String, newsgroup As String, limit As String)
  135.     Terminal.Status "Going into Usenet"
  136.     If Not GotoAreaOk(id, "Newsnet") Then
  137.         Exit Sub
  138.     End If
  139.     Terminal.Status "Joining " & newsgroup & " newsgroup"
  140.     Comms.Send "join " + newsgroup + " " + limit + "\r"
  141.     WaitForPrompt "Prompt"
  142.     ReportSuccess id & " : Subscribed to newsgroup " & newsgroup
  143.     Terminal.Status ""
  144. End Sub
  145.  
  146. 'T:ResignNewsgroup (subroutine) (CIX)
  147. Sub ResignNewsgroup(id As String, newsgroup As String)
  148.     Terminal.Status "Going into Usenet"
  149.     If Not GotoAreaOk(id, "Newsnet") Then
  150.         Exit Sub
  151.     End If
  152.     Terminal.Status "Resigning from " & newsgroup & " newsgroup"
  153.     Comms.Send "resign " + newsgroup + "\r"
  154.     WaitForPrompt "Prompt"
  155.     ReportSuccess id & " : Resigned from newsgroup " & newsgroup
  156.     Terminal.Status ""
  157. End Sub
  158.  
  159. 'T:RefreshNewsgroups (subroutine) (CIX)
  160. Sub RefreshNewsgroups(id As String)
  161.     Terminal.Status "Going into Usenet"
  162.     If Not GotoAreaOk(id, "Newsnet") Then
  163.         Exit Sub
  164.     End If
  165.     Terminal.Status "Collecting Newsgroup List"
  166.     Comms.Send "file newsgrouplist\r"
  167.     WaitForPrompt "Prompt"
  168.     Comms.Send "download newsgrouplist\r"
  169.     WaitFor "\*\*"
  170.     DeleteFile Session.ServicePath+"news.lis"
  171.     FileDownload PROT_ZMODEM, Session.ServicePath+"news.lis"
  172.     WaitFor "Newsnet:"
  173.     Comms.Send "killscratch\r"
  174.     WaitForPrompt "Prompt"
  175.     ReportSuccess id & " : Collected new newsgroup list"
  176.     Terminal.Status ""
  177. End Sub
  178.  
  179.  
  180.