home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1999-10-06 | 43.9 KB | 1,234 lines
'T:HMIFORUM.EBS for CompuServe ' VA 4.52 release ' 20.11.97 SH - included Taz' additions of improved Actions/Informations ' (waiting messages listed etc.) Declare Function ParseString(args As String, delim As String) As String Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean Declare Function StartMessageDownload(id As String, forum As String, sections As String, markunread As Boolean) As Integer Declare Sub SearchMessages(searchtype As Integer, searchstring As String, bodies As Boolean, rootsonly As Boolean, unreadonly As Boolean, lastdays As String) Declare Sub ReportSuccess(msg As String) Declare Function FullErrorMessage() As String Declare Sub ReadNumber(id As String, forum As String, number As String) Declare Sub FetchThread(id As String, forum As String, number As String) Declare Sub LogResult(result As String) Declare Function UniqueFileName$() Declare Sub AsciiListHeldMessages(id As String, forum As String, sections As String) Declare Function ParseSectionList(ByVal sect As String, ByVal validsects As Long, _ ByRef count As Integer) As Long Declare Sub SaveMessage(hdr As FAPMSGHEADER, body As String) Declare Function MakeDateString(s As HMITIMESTAMP) As String Declare Sub StartCapturing(pseudoforum As String, title As String, formatted As Boolean) Declare Sub FinishCapturing Declare Function SectionNumber(ByVal section As String) Declare Sub FinishMessageDownload(id As String) Declare Function SysOpGotoForum(byval forum as String) as Integer Declare sub LogSysOpConfig(byval forum as String) Const BlockSize = 2048 Const IM_DELETE = 2048 ' Delete scratchpad file afterwards? Const IM_MARKUNREAD = 131072 Const fRECEIPT = 1 Const fPRIVATE = 2 Const fNOFORMAT = 4 Public InAscii As Boolean Public WorkingPath As String 'added to speed up Fetch stuff online Public WhereAmI As String 'name of last forum/page etc Public Sysop As Boolean 'are we a sysop? Public Nisa As Boolean 'do we need to work round NISA "features" ? Public SetHighMessage As Boolean'True if you want a 'high;l' when leaving forum Public MailName As String Public currentCAP As Integer Public FAPconfig As FAPCONFIG Public SectionMsgIds(32) As Integer, SectionLibIds(32) As Integer Public szMsgSection() As FAPSECTIONENTRY, szLibSection() As FAPSECTIONENTRY Public nummessages As Integer Public CurrentForum As String Public LocalHMN As Boolean Dim LastDownMessages As String, capturefilename As String Dim messagefilename As String Dim sectionvector As Long, filterVector As Long Const ALL_HEADER_FIELDS% = &H1FF3 Const FAP_FDC_FILE_TYPE% = &H4 Const FAP_FDC_FILE_SIZE% = &H8 Const FAP_FDC_ABSTRACT% = &H100 Const FAP_SFH_FILENAME% = 0 Const FAP_SFH_USER_ID% = FAP_SFH_FILENAME + 1 Const FAP_SFH_KEYWORD% = FAP_SFH_USER_ID + 1 Const FAP_SFH_ACCESS_COUNT% = FAP_SFH_KEYWORD + 1 Const FAP_SFH_DATE_RANGE% = FAP_SFH_ACCESS_COUNT + 1 Const FAP_SFH_LAST_ACCESS_RANGE% = FAP_SFH_DATE_RANGE + 1 Const FAP_SFH_FILE_ABSTRACT% = FAP_SFH_LAST_ACCESS_RANGE + 1 Const FAP_SFH_FILE_BODY% = FAP_SFH_FILE_ABSTRACT + 1 Const FAP_SFH_MATCH_NON_PUBLIC_ONLY% = FAP_SFH_FILE_BODY + 1 Const FAP_SFH_SIZE_RANGE% = FAP_SFH_MATCH_NON_PUBLIC_ONLY + 1 Const FAP_SFH_TITLE% = FAP_SFH_SIZE_RANGE + 1 Const DAP_AL_VOLATILE = &H02 Const DAP_AP_SESSION_ONLY = &H01 Const DAP_AP_VOLATILE = &H02 Const DAP_AP_EX_HAVE_TITLE% = &H0100 Const DAP_AP_HAVE_HEADER% = &H04 Const DAP_AP_HAVE_TRAILER% = &H08 Const HMI_DATA_SIZE% = 1024 Const HMI_STATE_FIRST% = 0 Const HMI_STATE_NEXT% = HMI_STATE_FIRST + 1 Const FAP_USF_HIGH_MSG% = &H2 Const FAP_USF_NAME% = &H4 Const FAP_USR_JOIN% = &H1 Const FAP_USR_PERMANENT% = &H2 Const FAP_WAITING_MSGS% = &H1 Const FAP_NEW_BULLETINS% = &H2 Const FAP_CONFERENCE_IN_PROGRESS% = &H4 Const FAP_NOT_A_MEMBER% = &H8 Const FAP_IS_SYSOP% = &H10 ' user is SYSOP in this Forum Const FAP_FREE_USER% = &H20 Const FAP_LOCKED_OUT% = &H40 Const FAP_TRANSACTION_BILLING% = &H80 Const FAP_ALLOW_MULTIPLE_SEARCH% = &H100 Const FAP_NISA_FORUM% = &H200 Const FAP_MSS_ALL_MSGS% = 0 Const FAP_MSS_WAITING_MSGS% = FAP_MSS_ALL_MSGS + 1 Const FAP_MSS_SUBJECT_TEXT% = FAP_MSS_WAITING_MSGS + 1 Const FAP_MSS_ORIGINATOR_NAME% = FAP_MSS_SUBJECT_TEXT + 1 Const FAP_MSS_RECIPIENT_NAME% = FAP_MSS_ORIGINATOR_NAME + 1 Const FAP_MSS_MSGS_WITHOUT_REPLIES% = FAP_MSS_RECIPIENT_NAME + 1 Const FAP_MSS_HELD_MSGS% = FAP_MSS_MSGS_WITHOUT_REPLIES + 1 Const FAP_MSS_PRIVATE_MSGS% = FAP_MSS_HELD_MSGS + 1 ' to the user Const FAP_MSS_MSGS_WITHOUT_SYSOP_REPLIES% = FAP_MSS_PRIVATE_MSGS + 1 Const FAP_MSS_MESSAGE_BODY% = FAP_MSS_MSGS_WITHOUT_SYSOP_REPLIES + 1 Const FAP_MSS_POSTING_DATE_RANGE% = FAP_MSS_MESSAGE_BODY + 1 Const FAP_MSS_EXPIRATION_DATE_RANGE% = FAP_MSS_POSTING_DATE_RANGE + 1 Const FAP_MSS_MESSAGES_HAS_BEEN_READ% = FAP_MSS_EXPIRATION_DATE_RANGE + 1 Const FAP_NO_MESSAGE_READ% = &H1 Const FAP_NO_MESSAGE_SEND% = &H2 Const FAP_NO_LIBRARY_READ% = &H4 Const FAP_NO_LIBRARY_SEND% = &H8 Const FAP_NO_CONFERENCE% = &H10 Const FAP_NO_PRIVATE_MSGS% = &H20 Const FAP_NO_MEMBERSHIP% = &H80 Const FAP_PRIVATE_FORUM% = &H100 Const FAP_RTC_CONFIG_SUPPORTED% = &H200 Const FAP_SEARCH_LIBRARY_ABSTRACTS% = &H400 ' Full text search of file abstrats allowed Const FAP_SEARCH_LIBRARY_FILES% = &H800 ' Search text file contents Const FAP_SEARCH_MESSAGE_BODIES% = &H1000 ' Searching message bodies allowed Const FAP_LIBRARY_ONLY_FORUM% = &H2000 Const FAP_PRIVATE_MESSAGE% = &H1 Const FAP_EXTENDED_MESSAGE% = &H80 Const FAP_MC_THREAD_ID% = &H1000 Const FAP_MC_THREADS% = &H8000 Const FAP_MSR_PSEUDO_ROOTS% = &H80 Sub SetHighMessageNumber() Dim b As Integer ' Don't set HMN if HMI error If Err = 1009 Then Err = 0 SetHighMessage = False End If If SetHighMessage Then If currentCAP = CAP_FORUM Then Terminal.Print "Updating the high message number to " & FAPconfig.dwNewestMsg & " in " & CurrentForum & Basic.Eoln$ b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, FAPconfig.dwNewestMsg, "") WriteIni "High Message Number", WhereAmI, LTrim$(Str$(FAPconfig.dwNewestMsg)), Session.ServicePath+"hmn.ini" End If SetHighMessage = False End If End Sub 'T:CollectSections Sub CollectSections(forum As String) Dim sctMsg As FAPSECTIONS, sctLib As FAPSECTIONS Dim i As Integer Dim sNam As String Dim bMessages As Integer, bLibraries As Integer ' Initialise variables For i = 0 To 32 SectionMsgIds(i) = -1 SectionLibIds(i) = -1 Next ' We must be a member If FAPconfig.wAlerts And FAP_NOT_A_MEMBER% Then Exit Sub End If Terminal.Print "Collecting section information" + Basic.Eoln$ On Error Goto CollectMsgSections_error ' Get the msg section names for the forum from Compuserve FAPReadMsgSections sctMsg, szMsgSection() For i = 0 To UBound(szMsgSection) sectionMsgIds(szMsgSection(i).cId) = i ReplaceAnyInString szMsgSection(i).lpTitle, " /", "_" Next bMessages = True CollectMsgSections_resume: ' Get the lib section names for the forum from Compuserve On Error Goto CollectLibSections_error FAPReadLibSections sctLib, szLibSection() For i = 0 To UBound(szLibSection) sectionLibIds(szLibSection(i).cId) = i ReplaceAnyInString szLibSection(i).lpTitle, " /", "_" Next bLibraries = True CollectLibSections_resume: On Error Goto 0 Err = 0 ' Cope with ZNT:<forum> If InStr(forum, ":")<>0 Then sNam = Mid$(forum, InStr(forum, ":")+1, 8)+".nam" Else sNam = Mid$(forum, 1, 8)+".nam" End If ' Create the .NAM file DeleteFile Session.ServicePath+sNam Capture CAPTURE_ON, Session.ServicePath+sNam If InStr(forum, ":")<>0 Then CaptureLine "#forum " + Mid$(forum, InStr(forum, ":")+1) Else CaptureLine "#forum " + forum End If ' Write forum info If (FAPconfig.wAlerts And FAP_IS_SYSOP%)<>0 Then CaptureLine "SYSOP" If (FAPconfig.wAlerts And FAP_FREE_USER%)<>0 Then CaptureLine "Free Flag" If (FAPconfig.wAlerts And FAP_NISA_FORUM%)<>0 Then CaptureLine "NISA Forum" If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%)<>0 Then CaptureLine "Private Messages not allowed" Else CaptureLine "Private Messages are allowed" End If On Error Resume Next ' Get the message section names for the forum from Compuserve CaptureLine "Message Sections Available:" If bMessages Then For i = 0 To UBound(szMsgSection) CaptureLine Str(szMsgSection(i).cId)+" "+szMsgSection(i).lpTitle Next End If ' Get the library section names for the forum from Compuserve CaptureLine "Libraries Available:" If bLibraries Then For i = 0 To UBound(szLibSection) CaptureLine Str(szLibSection(i).cId)+" "+szLibSection(i).lpTitle Next End If ' Clear up Capture CAPTURE_OFF On Error Goto 0 Exit Sub CollectMsgSections_error: Resume CollectMsgSections_resume CollectLibSections_error: Resume CollectLibSections_resume End Sub ' Intelligently GO forum only Function HMIGotoForum(ByVal forum As String) As Boolean Dim filename As String, myerror As String, i As Integer Dim fname As String, preforum As String, tmp As String Dim forumname as String ' Sort out any switch between ascii/hmi If InAscii Then ResetForum InAscii = False End If ' Mangle the forum name a bit forum = ParseString(forum, "/") fname = forum If Instr(forum, ":")=0 Then forum = "cis:"+forum End If ' Use the lookup table to auto-convert menus to forums. ' eg. 'PCPLUS' -> 'PCPFORUM' preforum = forum forum = LookupForum(preforum) ' If we're already here then do nothing If StrComp(WhereAmI, fname, 1)<>0 And StrComp(WhereAmI, forum, 1)<>0 _ And StrComp(WhereAmI, preforum, 1)<>0 Then SetHighMessageNumber If StrComp(WhereAmI, "home:mail", 1)<>0 Then If WhereAmI<>"" Then Terminal.Print "Leaving " & WhereAmI & Basic.Eoln$ & Basic.Eoln$ End If End If Terminal.Print Basic.Eoln$+"Go " & forum & Basic.Eoln$ & Basic.Eoln$ On Error Goto GoForum_error HMIGotoForum = False If Not DoHMIGotoPage(forum, -1, CAP_FORUM, False) Then If currentCAP <> CAP_ERROR Then myerror = "Not a forum" goto GoForum_error End If HMIGetFAPConfig FAPconfig Sysop = ((FAPconfig.wAlerts And FAP_IS_SYSOP%) <> 0) Nisa = ((FAPconfig.wAlerts And FAP_NISA_FORUM%) <> 0) Terminal.Print "Welcome to " & FAPconfig.lpForumName & " Forum" & Basic.Eoln$ Terminal.Print "Hello, " & FAPconfig.lpUserName If Sysop Then Terminal.Print " (Sysop)" If (FAPconfig.wAlerts And FAP_FREE_USER%)<>0 Then Terminal.Print " (Free)" Terminal.Print Basic.Eoln$ If Nisa Then Terminal.Print "This is a NISA forum" & Basic.Eoln$ If FAPconfig.tsLastAccess.cYear>0 Then Terminal.Print "Last visit: " & MakeDateString(FAPconfig.tsLastAccess) & Basic.Eoln$ Else Terminal.Print "Last visit: Never" & Basic.Eoln$ End If Terminal.Print "Forum messages: " & FAPconfig.dwMsgNoBase & " to " & FAPconfig.dwNewestMsg & Basic.Eoln$ Terminal.Print "Last message you've read: " & FAPconfig.dwLastMsgRead & Basic.Eoln$ If LocalHMN Then If Instr(fname,":")=0 then tmp = "cis:"+fname Else tmp=fname End If Terminal.Print "Using local HMN for " & tmp & ": " tmp = ReadIni$("High Message Number", tmp, Session.ServicePath+"hmn.ini") Terminal.Print tmp & Basic.Eoln$ If Val(tmp) > 0 And Val(tmp)<>FAPconfig.dwLastMsgRead Then b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, Val(tmp), "") HMIGetFAPConfig FAPconfig End If End If If FAPconfig.wAlerts And FAP_WAITING_MSGS% Then Terminal.Print Basic.Eoln$ & "You have waiting message(s)" & Basic.Eoln$ End If Terminal.Print Basic.Eoln$ If FAPconfig.wAlerts And FAP_LOCKED_OUT% Then myerror = "User locked out" goto GoForum_error End If If FAPconfig.wAlerts And FAP_NEW_BULLETINS% Then Terminal.Print "Collecting updated Newsflash" + Basic.Eoln$ RecordBulletins fname, True, False, False End If Terminal.Status "HMIGotoForum: "+fname On Error Goto 0 ' It all worked If Instr(fname, ":")=0 Then WhereAmI = "cis:"+fname Else WhereAmI = fname End If CollectSections WhereAmI If Sysop And Nisa Then i = SysOpGotoForum(Mid$(fname, InStr(fname, ":")+1)) End If End If LastFailure = "" HMIGotoForum = True Exit Function GoForum_error: On Error Goto 0 If myerror = "" Then myerror = FullErrorMessage Terminal.Print "Error: " & myerror & Basic.Eoln$ LogResult "HMIGotoForum : "+forum+" : Failed Error : "+myerror LastFailure = forum SetHighMessage = False ' If it was a PTE and HMI packet size was 2k then reduce to 1k and inform ' the user. If InStr(myerror, "1285:Protocol transport error", 1)<>0 And _ ReadIni$(Session.IniSection, "HMI Packet Size", Session.IniFilename)="2048" Then WriteIni Session.IniSection, "HMI Packet Size", "1024", Session.IniFilename LogResult "_NOTE_Reducing_HMI_packet_size_for_improved_connection_reliability_" End If If InStr(myerror, "1285:Protocol transport error", 1)<>0 And _ ReadIni$(Session.IniSection, "HMI Packet Size", Session.IniFilename)="4096" Then WriteIni Session.IniSection, "HMI Packet Size", "2048", Session.IniFilename LogResult "_NOTE_Reducing_HMI_packet_size_for_improved_connection_reliability_" End If End Function 'T:SetHigh (subroutine) (CompuServe) ' Set high message number Sub SetHigh(id As String, forum As String, num As String) Dim hmn As Long, b As Integer If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to set high message number in "+forum Exit Sub End If hmn = Val(num) If hmn < 0 Then hmn = FAPconfig.dwNewestMsg+hmn If hmn = 0 Then hmn = FAPconfig.dwNewestMsg ' Set high number Terminal.Print "Setting the high message number to" & Str(hmn) & Basic.Eoln$ b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, hmn, "") WriteIni "High Message Number", WhereAmI, LTrim$(Str$(hmn)), Session.ServicePath+"hmn.ini" If id<>"" Then If b=0 Then ReportSuccess id & " : Failed to Set High Message Number to #" & hmn & " in " & forum Else ReportSuccess id & " : Set High Message Number to #" & hmn & " in " & forum HMIGetFAPConfig FAPconfig End If Else HMIGetFAPConfig FAPconfig End If End Sub Function CheckTopicBeforePosting(id As String, topic As String, _ section As Integer, subject As String, checksection As Boolean) As Boolean Dim i As Integer If Not HMIGotoForum(topic) Then LogResult id + " : Failed : Unable to post message." Exit Function End If If FAPconfig.wRestrictions And FAP_NO_MESSAGE_SEND% Then LogResult id + " : Failed : Posting not allowed in forum " & topic Exit Function End If ' Truncate subject to 24 chars and make it valid If Len(subject) > 24 Then subject = Left$(subject, 24) For i = 1 To Len(subject) If InStr(";""", Mid(subject, i, 1)) Then Mid(subject, i, 1) = " " Next section = Val(SectionNumber(topic)) If checksection Then If (FAPconfig.svMsgSections And (2 ^ section)) = 0 Then LogResult id + " : Failed : Unknown section " & topic Exit Function End If End If CheckTopicBeforePosting = True End Function 'T:Say (subroutine) (CompuServe) Sub Say(id As String, topic As String, pfrom As String, pto As String, flags As Integer, subject As String, filename As String) Dim hdr As FAPMSGHEADER, body As String Dim section As Integer, cOptions As Integer Dim username As String, userid As String, lastname As String Dim noformat As Integer, b As Integer ' Is it usenet? If Mid(topic, 1, 7)="usenet." Then UsenetPost id, topic, filename Exit Sub End If If Not CheckTopicBeforePosting(id, topic, section, subject, True) Then Exit Sub End If If (flags And fPRIVATE)=fPRIVATE Then Terminal.Print "Posting private message to " + pto + " Subj: " + subject + Basic.Eoln$ Else Terminal.Print "Posting message to " + pto + " Subj: " + subject + Basic.Eoln$ End If AnalyseName pto, username, userid If StrComp(userid, "all", 1)=0 Or _ StrComp(userid, "sysop", 1)=0 Or _ StrComp(userid, "*sysop", 1)=0 Then username = userid userid = "" End If ' What posting flags ? cOptions = 0 noformat = 0 If flags And fNOFORMAT Then noformat = 1 If (flags And fPRIVATE)=fPRIVATE Then If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%) = 0 Then cOptions = FAP_PRIVATE_MESSAGE% Else MailTo id, pto, 0, subject, filename SendMail id Exit Sub End If End If ' Strip off "@cs.com" and "internet:" ? If InStr(userid, "internet:", 1)=1 And InStr(userid, "@cs.com", 1)<>0 Then userid = Mid$(userid, 10, InStr(userid, "@cs.com")-10) End If ' What's our name If pfrom <> "" Then On Error Resume Next lastname = FAPconfig.lpUserName b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, pfrom) On Error Goto 0 End If ' Get body text body = ReadMessageFile(filename, 2) On Error Goto Say_error On Error Resume Next 'NB Bug in CCT230B always gives error here FAPSendMsg hdr, section, subject, username, userid, cOptions, body ' Change back to old name If lastname <> "" Then On Error Resume Next b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, lastname) On Error Goto 0 End If If hdr.dwMsgNo = 0 Then LogResult id + " : Failed : Posting Compose to " & topic Else ReportSuccess id & " : Posted Compose to " & pto & " as VA:" & Session.Service & ":" & topic & "#" & hdr.dwMsgNo HMIGetFAPConfig FAPconfig End If Exit Sub Say_error: LogResult id + " : Failed : Posting Compose to " & topic & " - Error:" & FullErrorMessage End Sub 'T:UnjoinedSay (subroutine) (CompuServe) Sub UnjoinedSay(id As String, topic As String, pto As String, subject As String, filename As String) Say id, topic, "", pto, 0, subject, filename End Sub 'T:Comment (subroutine) (CompuServe) Sub Comment(id As String, topic As String, pfrom As String, pto As String, message As String, flags As Integer, subject As String, filename As String) Dim hdr As FAPMSGHEADER, body As String Dim section As Integer, cOptions As Integer Dim username As String, userid As String, lastname As String Dim msgno As Long, threadid As Long Dim noformat As Integer ' Is it usenet? If Mid(topic, 1, 7)="usenet." Then UsenetPost id, topic, filename Exit Sub End If If Not CheckTopicBeforePosting(id, topic, section, subject, False) Then Exit Sub End If If (flags And fPRIVATE)=fPRIVATE Then Terminal.Print "Replying privately to message #"+message+" Subj: "+subject+Basic.Eoln$ Else Terminal.Print "Replying to message #"+message+" Subj: "+subject+Basic.Eoln$ End If ' What posting flags ? cOptions = 0 noformat = 0 If flags And fNOFORMAT Then noformat = 1 If (flags And fPRIVATE)=fPRIVATE Then If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%) = 0 Then cOptions = FAP_PRIVATE_MESSAGE% Else MailTo id, pto, 0, "Re: "+subject, filename SendMail id Exit Sub End If End If ' What's our name If pfrom <> "" Then On Error Resume Next lastname = FAPconfig.lpUserName b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, pfrom) On Error Goto 0 End If ' Collect message text ready to send to CIS body = ReadMessageFile(filename, 2) On Error Resume Next msgno = Val(message) FAPReadMsgHeader hdr, msgno, FAP_MC_THREAD_ID% threadid = hdr.dwThreadID If threadid <> 0 Then FAPSendReply hdr, msgno, threadid, cOptions, body Else hdr.dwMsgNo = 0 End If If hdr.dwMsgNo = 0 Then AnalyseName pto, username, userid FAPSendMsg hdr, section, "#"+message+"-"+subject, username, userid, cOptions, body If hdr.dwMsgNo = 0 Then LogResult id + " : Failed : Posting Reply to VA:" & Session.Service & ":" & topic & "#" & message & " - error: " & FullErrorMessage() ' Change back to old name If lastname <> "" Then On Error Resume Next b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, lastname) On Error Goto 0 End If Exit Sub End If End If ReportSuccess id & " : Posted Reply to " & message & " as VA:" & Session.Service & ":" & topic & "#" & hdr.dwMsgNo ' Change back to old name If lastname <> "" Then On Error Resume Next b = FAPSetUserProfile(0, FAP_USF_NAME%, 0, lastname) On Error Goto 0 End If HMIGetFAPConfig FAPconfig Exit Sub End Sub 'T:DownMessages (subroutine) (CompuServe) ' Download full message text Sub DownMessages(id As String, forum As String, sections As String) Dim hdr As FAPMSGHEADER, sect As Long Dim txt As String, body As String, t As String Dim count As Integer, i As Integer, newmsgs As Long sections = Trim$(LTrim$(sections)) If StartMessageDownload(id, forum, sections, False) Then On Error Goto DownMessages_error sect = ParseSectionList(sections, FAPconfig.svMsgSections, count) If count > 0 Then Dim lpStartWith(0 To count-1) As FAPSTARTWITH 'Fill in the FAPSTARTWITH structures for each section count = 0 For i = 0 To 24 sl = 2^i If (sect And (2^i))<>0 Then lpStartWith(count).cSectionID = i lpStartWith(count).dwMsgNo = FAPconfig.dwLastMsgRead count = count + 1 End If Next 'Ask HMI for all new messages after the start FAPReadNewMsgs ALL_HEADER_FIELDS%, lpStartWith() 'Now read the actual messages Do hdr.dwMsgNo = 0 FAPReadSingleNewMsgHdr hdr If hdr.dwMsgNo = 0 Then Exit Do 'Finished body = "" Do txt = "" ' possible memory leak txt = FAPReadNewMessageBody(hdr) body = body + txt Loop While txt > "" SaveMessage hdr, body newmsgs = newmsgs + 1 Loop End If Terminal.Print "Collected " & newmsgs & " new message(s)" & Basic.Eoln$ If count>0 Then SetHighMessage = True End If FinishMessageDownload id Exit Sub DownMessages_error: LogResult "Error:" & FullErrorMessage & " collecting messages from " & forum CaptureLine "Error:" & FullErrorMessage FinishMessageDownload id End Sub Dim ThreadsToFetch() As Long, MsgsToFetch() As Long, nMsgsToFetch As Integer ' Scans the array of thread ids marked to fetch and flags this one if ' it's found Function SetFetchThreadId(threadid As Long, num As Long) As Boolean Dim i As Integer, lin As String, file As String ' First call - load list of threadids marked to fetch If threadid=0 Then file$ = ReadIni$("Main", "Message Path", Session.IniFilename) + _ Session.Service + "\" + _ Mid$(WhereAmI$, InStr(WhereAmI$, ":")+1, 8) + ".tid" i = 0 nMsgsToFetch = -1 ReDim Preserve MsgsToFetch(0 to 0) ReDim Preserve ThreadsToFetch(0 To 0) On Error Goto Read_Error Open file$ For Input As #1 Do While Not EOF(1) Line Input #1,lin$ ReDim Preserve ThreadsToFetch(0 To i) ThreadsToFetch(i) = Val(lin$) i = i + 1 Loop Read_error: Close #1 SetFetchThreadId = False Else ' Set the fetch flag For i=0 To UBound(ThreadsToFetch) If ThreadsToFetch(i)=threadid Then nMsgsToFetch = nMsgsToFetch + 1 ReDim Preserve MsgsToFetch(0 To nMsgsToFetch) MsgsToFetch(nMsgsToFetch) = num Terminal.Print "Need to fetch thread#"+Str$(threadid)+basic.eoln$ SetFetchThreadId = False Exit Function End If Next SetFetchThreadId = True End If End Function 'T:DownHeaders (subroutine) (CompuServe) Sub DownHeaders(id As String, forum As String, sections As String) Dim tforum As String nMsgsToFetch = -1 tforum = forum If StartMessageDownload(id, tforum, sections, False) Then SearchMessages FAP_MSS_ALL_MSGS%, "", False, False, True, "" If Len(Trim$(LTrim$(sections)))>0 Then SetHighMessage = True End If FinishMessageDownload id ' Now fetch any full messages that the user wanted If nMsgsToFetch >= 0 Then For i=0 To nMsgsToFetch If MsgsToFetch(i) > 0 Then tforum = forum ReadNumber "", tforum, LTrim$(Str$(MsgsToFetch(i))) End If Next End If End Sub 'T:DownRoots (subroutine) (CompuServe) Sub DownRoots(id As String, forum As String, sections As String) Dim tforum As String nMsgsToFetch = -1 tforum = forum If StartMessageDownload(id, tforum, sections, False) Then SearchMessages FAP_MSS_ALL_MSGS%, "", False, True, True, "" If Len(Trim$(LTrim$(sections)))>0 Then SetHighMessage = True End If FinishMessageDownload id ' Now fetch any full messages that the user wanted If nMsgsToFetch >= 0 Then For i=0 To nMsgsToFetch If MsgsToFetch(i) > 0 Then tforum = forum FetchThread "", tforum, LTrim$(Str$(MsgsToFetch(i))) End If Next End If End Sub 'T:SearchForMessages (subroutine) (CompuServe) Sub SearchForMessages(id As String, forum As String, sections As String, lastdays As String, searchtype As String, searchstring As String) Dim hmn As Long If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect messages from " + forum Exit Sub End If If searchtype="9" And Nisa=False Then LogResult id + " : Failed : Cannot search message body in non-NISA forum " + forum Exit Sub End If hmn = FAPconfig.dwLastMsgRead If StartMessageDownload(id, forum, sections, True) Then If lastdays="u" Then Terminal.Print "Searching for unread messages " Else Terminal.Print "Searching for messages " End If If searchtype="2" Then Terminal.Print "with subject: '" If searchtype="3" Then Terminal.Print "from: '" If searchtype="4" Then Terminal.Print "to: '" If searchtype="9" Then Terminal.Print "containing: '" Terminal.Print searchstring+"'"+Basic.Eoln$ If lastdays="u" Then SearchMessages Val(searchtype), searchstring, True, False, True, "" Else SearchMessages Val(searchtype), searchstring, True, False, False, lastdays End If End If FinishMessageDownload id ' Correct Compuserve's invalid assumption about HMN after remote search b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, hmn, "") End Sub 'T:ListHeldMessages (subroutine) (CompuServe) Sub ListHeldMessages(id As String, forum As String, sections As String) Dim term(0 To 0) As FAPSEARCHTERM Dim summary() As FAPMSGSUMMARY Dim msgno() As Long Dim hdr As FAPMSGHEADER Dim i As Integer, count as Integer Dim nmsgs As Integer Dim cComponents As Integer Dim dwStart As Long Dim section As String If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect messages from " + forum Exit Sub End If If Nisa Then sectionvector = ParseSectionList(sections, FAPconfig.svMsgSections, count) StartCapturing forum+"/Sysop_Logs", "Held_Messages", False CaptureLine "Messages on Hold" CaptureLine "" Terminal.Status "Collecting Held List ... Please Wait" term(0).cType = FAP_MSS_HELD_MSGS% dwStart = FAPconfig.dwMsgNoBase On Error Goto ListHeldMessages_end FAPMsgSearch summary(), msgno(), HMI_STATE_FIRST%, 1, 20, _ sectionvector, dwStart, cComponents, term() While True nmsgs = UBound(msgno) On Error Goto ListHeldMessages_error For i = 0 To UBound(msgno) hdr.dwMsgNo = 0 FAPReadMsgHeader hdr, msgno(i), ALL_HEADER_FIELDS% If hdr.dwMsgNo = 0 Then Exit For If SectionMsgIds(hdr.cSectionId) >= 0 Then section = szMsgSection(SectionMsgIds(hdr.cSectionId)).lpTitle Else section = "Unknown" End If CaptureText "VA:" & Session.Service & ":" & forum & "/S" & hdr.cSectionId CaptureLine "_" & section & "#" & hdr.dwMsgNo Next On Error Goto ListHeldMessages_end ' following will error if nothing else left FAPMsgSearch summary(), msgno(), HMI_STATE_NEXT%, 1, 20, _ sectionvector, dwStart, cComponents, term() Wend ListHeldMessages_end: FinishCapturing ReportSuccess id & " : Held Message List for forum " & forum & " collected" Exit Sub ListHeldMessages_error: LogResult "SearchMessages: Error:" & FullErrorMessage Else AsciiListHeldMessages id, forum, sections End If End Sub Sub FetchMessageThread(id As String, forum As String, number As String, thr As Boolean) Dim i As Integer, b As Integer, done As Integer Dim tmp As String, body As String, txt As String, tforum As String Dim hdr As FAPMSGHEADER, msgno() As Long, lasthmn As Long If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to read messages from " + forum Exit Sub End If ' Check to see if we need to join the forum If ((FAPconfig.wAlerts And FAP_NOT_A_MEMBER%) <> 0) Then tforum = forum tforum = ParseString(tforum, "/") JoinForum "", tforum, MailName, "" End If lasthmn = FAPconfig.dwLastMsgRead CurrentForum = ParseString(forum, "/") ' Unique name for capture file messagefilename = UniqueFileName$() Capture CAPTURE_ON, messagefilename CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=yes;deleteexisting=no"+Basic.Eoln$ On Error Goto ReadMessageThread_error ' Read the message/thread Redim msgno(0 To 0) msgno(0) = number If thr Then FAPReadMessageHeaders ALL_HEADER_FIELDS%+FAP_MC_THREADS%, msgno() Else FAPReadMessageHeaders ALL_HEADER_FIELDS%, msgno() End If done = False Do FAPReadSingleMsgHdr hdr If hdr.dwMsgNo = 0 Then Exit Do If thr Then Terminal.Print "Reading thread #" & LTrim(Str(hdr.dwMsgNo)) & " " & hdr.lpSubject & Basic.Eoln$ Else Terminal.Print "Reading message #" & LTrim(Str(hdr.dwMsgNo)) & " " & hdr.lpSubject & Basic.Eoln$ End If body = "" Do txt = FAPReadMessageBody(hdr) body = body + txt Loop While txt > "" SaveMessage hdr, body done = True Loop If done = False And thr = False Then Terminal.Print "% Unable to read message #" & number & " from " & WhereAmI & Basic.Eoln$ End If Capture CAPTURE_OFF If done Then If id<>"" Then ReportSuccess id & " : Collected message/thread #" & number & " from " & WhereAmI b = QueueFile(Session.Service, messagefilename, IM_DELETE) Else If id<>"" Then ReportSuccess id & " : Didn't collect message/thread #" & number & " from " & WhereAmI DeleteFile messagefilename End If i = HMIResync(CAP_FORUM) ' Need to set HMN because CIS messes it up b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_HIGH_MSG%, lasthmn, "") Exit Sub ReadMessageThread_error: LogResult "Error:" & FullErrorMessage & " collecting message/thread from " & forum CaptureLine "Error:" & FullErrorMessage i = HMIResync(CAP_FORUM) sectionvector = 0 End Sub Sub FetchThread(id As String, forum As String, number As String) FetchMessageThread id, forum, number, True End Sub Function StartMessageDownload(id As String, forum As String, _ sections As String, markunread As Boolean) As Integer Dim i As Integer, j As Integer, count As Integer Dim tmp As String, t As String Dim tmpVector As Long, fromyou As Boolean nummessages = -1 StartMessageDownload = False If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect messages from " + forum Exit Function End If CurrentForum = forum ' Unique name for capture file Capture CAPTURE_ON, WorkingPath + "mswfetch.tmp" CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=no;deleteexisting=no"+Basic.Eoln$ Terminal.CaptureStatus CAPTURE_ON nummessages = 0 On Error Goto StartMessageDownload_error ' Which sections ? fromyou = InStr(sections, "y", 1)<>0 ReplaceAllInString sections, " y", "" sectionvector = ParseSectionList(sections, FAPconfig.svMsgSections, count) ' Messages from/to you If LastDownMessages<>WhereAmI Then filterVector = sectionvector ' Used to filter out waiting messages tmpVector = sectionvector sectionvector = &HFFFFFFFF If FAPconfig.wAlerts And FAP_WAITING_MSGS% Then Terminal.Print "Collecting waiting messages" & Basic.Eoln$ SearchMessages FAP_MSS_WAITING_MSGS%, "", True, False, False, "" If nummessages=1 Then Terminal.Print "Collected 1 waiting message" & Basic.Eoln$ Else Terminal.Print "Collected " & nummessages & " waiting messages" & Basic.Eoln$ End If nummessages = 0 End If ' Read messages from you? If fromyou Then Terminal.Print "Collecting messages from you" & Basic.Eoln$ SearchMessages FAP_MSS_ORIGINATOR_NAME%, Session.LoginName, True, False, True, "" End If sectionvector = tmpVector End If ' Start capture Capture CAPTURE_OFF messagefilename = UniqueFileName$() Capture CAPTURE_ON, messagefilename If markunread Then CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=yes;deleteexisting=no"+Basic.Eoln$ Else CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=no;deleteexisting=no"+Basic.Eoln$ End If ' Store the last forum we read messages from so that we don't ' do more than one reading waiting per forum. LastDownMessages = WhereAmI If Not markunread Then If sectionvector=FAPconfig.svMsgSections Then Terminal.Print "Collecting messages from all sections" + Basic.Eoln$ Else Terminal.Print "Collecting messages from sections " + Trim$(sections) + Basic.Eoln$ End If End If StartMessageDownload = True Exit Function StartMessageDownload_error: LogResult "Error:" & FullErrorMessage & " collecting messages from " & forum CaptureLine "Error:" & FullErrorMessage sectionvector = 0 If nummessages > 0 Then StartMessageDownload = True End Function Sub FinishMessageDownload(id As String) Capture CAPTURE_OFF Terminal.CaptureStatus CAPTURE_OFF If nummessages = -1 Then Exit Sub If nummessages = 1 Then ReportSuccess id & " : Collected " & nummessages & " message from " & _ WhereAmI & " [" & LTrim$(Str$(FAPconfig.dwLastMsgRead)) & "-" & _ LTrim$(Str$(FAPconfig.dwNewestMsg)) & "]" Else ReportSuccess id & " : Collected " & nummessages & " messages from " & _ WhereAmI & " [" & LTrim$(Str$(FAPconfig.dwLastMsgRead)) & "-" & _ LTrim$(Str$(FAPconfig.dwNewestMsg)) & "]" End If If nummessages > 0 Then ' Add to import queue b = QueueFile(Session.Service, messagefilename, IM_DELETE) Else DeleteFile messagefilename End If End Sub Sub SearchMessages(searchtype As Integer, searchstring As String, bodies As Boolean, rootsonly As Boolean, unreadonly As Boolean, lastdays As String) Dim term(0 To 0) As FAPSEARCHTERM Dim summary() As FAPMSGSUMMARY Dim msgno() As Long Dim hdr As FAPMSGHEADER Dim i As Integer, txt As String, body As String Dim nmsgs As Integer Dim d As Date, tsTime As HMITIMESTAMP Dim cComponents As Integer Dim dwStart As Long Dim saveit As Boolean Dim Section as String ' Nothing to do so don't bother trying If unreadonly And FAPconfig.dwNewestMsg=FAPconfig.dwLastMsgRead Then Exit Sub End If term(0).cType = searchtype If searchstring<>"" Then term(0).lpPattern = searchstring If rootsonly Then cComponents = FAP_MSR_PSEUDO_ROOTS% saveit = SetFetchThreadId(0, 0) End If If lastdays<>"" Then d = Date() - Val(lastdays) tsTime.cDay = Day(d) tsTime.cMonth = Month(d) tsTime.cYear = Year(d)-1970 dwStart = FAPSearchDate(&H00FFFFFF, tsTime) Else If unreadonly Then dwStart = FAPconfig.dwLastMsgRead Else dwStart = FAPconfig.dwMsgNoBase End If End If Terminal.CaptureStatus CAPTURE_ON On Error Goto SearchMessages_end FAPMsgSearch summary(), msgno(), HMI_STATE_FIRST%, 1, 1000, _ sectionvector, dwStart, cComponents, term() While True nmsgs = UBound(msgno) On Error Goto SearchMessages_error If bodies Then FAPReadMessageHeaders ALL_HEADER_FIELDS%, msgno() Do FAPReadSingleMsgHdr hdr If hdr.dwMsgNo = 0 Then Exit Do dwStart = hdr.dwMsgNo body = "" Do txt = "" ' possible memory leak txt = FAPReadMessageBody(hdr) body = body + txt Loop While txt > "" SaveMessage hdr, body If SearchType = FAP_WAITING_MSGS% Then If SectionMsgIds(hdr.cSectionId) >= 0 Then section = szMsgSection(SectionMsgIds(hdr.cSectionId)).lpTitle Else section = "Unknown" End If LogResult "Collected Waiting Message : VA:" & Session.Service & ":" & CurrentForum & "/S" & hdr.cSectionId & "_" & Section & "#" & hdr.dwMsgNo End If Loop Else For i = 0 To UBound(msgno) hdr.dwMsgNo = 0 If rootsonly Then FAPReadMsgHeader hdr, msgno(i), &H1FE3 saveit = SetFetchThreadId(hdr.dwThreadId, hdr.dwMsgNo) Else FAPReadMsgHeader hdr, msgno(i), ALL_HEADER_FIELDS% saveit = True End If If hdr.dwMsgNo = 0 Then Exit For If saveit Then SaveMessage hdr, "*** Header Only ***" & Chr$(10) Next End If On Error Goto SearchMessages_end ' following will error if nothing else left FAPMsgSearch summary(), msgno(), HMI_STATE_NEXT%, 1, 1000, _ sectionvector, dwStart, cComponents, term() Wend SearchMessages_end: filterVector = 0 Terminal.CaptureStatus CAPTURE_OFF Exit Sub SearchMessages_error: Terminal.CaptureStatus CAPTURE_OFF LogResult "SearchMessages: Error:" & FullErrorMessage filterVector = 0 End Sub 'T:ReadNumber (subroutine) (CompuServe) Sub ReadNumber(id As String, forum As String, number As String) FetchMessageThread id, forum, number, False End Sub 'T:JoinForum (subroutine) (CompuServe) Sub JoinForum(id As String, forum As String, handle As String, newmsgs As String) Dim b As Integer, hmn As Long Dim tsTime As HMITIMESTAMP, d As Date Dim a As Boolean If Not HMIGotoForum(forum) Then LogResult "Unable to join "+forum Exit Sub End If Terminal.Print "Joining forum"+Basic.Eoln$ On Error Goto JoinForum_error ' Set user name If ((FAPconfig.wAlerts And FAP_NOT_A_MEMBER%) <> 0) Then b = FAPSetUserProfile(FAP_USR_PERMANENT%+FAP_USR_JOIN%, FAP_USF_NAME%, 0, handle) FAPconfig.wAlerts = FAPconfig.wAlerts - FAP_NOT_A_MEMBER% Else On Error Resume Next b = FAPSetUserProfile(FAP_USR_PERMANENT%, FAP_USF_NAME%, 0, handle) End If ' Get list of sections/libraries CollectSections forum If (FAPconfig.wAlerts And FAP_NEW_BULLETINS)=0 Then Newsflash "", forum End If Announcements "", forum ' Set HMN back nnn messages If newmsgs <> "" Then hmn = FAPconfig.dwNewestMsg - Val(newmsgs) If hmn > 0 Then SetHigh "", forum, LTrim$(Str(hmn)) ElseIf FAPconfig.dwLastMsgRead < FAPconfig.dwMsgNoBase Then SetHigh "", forum, LTrim$(Str(FAPconfig.dwMsgNoBase)) End If ReportSuccess id & " : Joined " & forum & " successfully" Exit Sub JoinForum_error: LogResult id + " : Failed : Unable to join " + forum + " - error:" + FullErrorMessage End Sub 'T:UserLog (subroutine) (CompuServe) Sub UserLog(id As String, forum As String) If Not HMIGotoForum(forum) Then LogResult id + " : Failed : Unable to collect user log from "+forum Exit Sub End If If Not Nisa Then AsciiUserLog id, forum Exit Sub End If Terminal.Print "Collecting forum user log ... Please wait"+Basic.Eoln$ RecordBulletins forum, False, False, True If id<>"" Then ReportSuccess id & " : User log collected from " & forum End Sub 'T:RecordSectionInformation (subroutine) (CompuServe) Sub RecordSectionInformation(forum As String) Dim i As Integer, buf As String StartCapturing forum+"/Announcements", "CompuServe", True CaptureLine "Sections" If (FAPconfig.wAlerts And FAP_IS_SYSOP%)<>0 Then CaptureLine "SYSOP" If (FAPconfig.wAlerts And FAP_FREE_USER%)<>0 Then CaptureLine "Free Flag" If (FAPconfig.wAlerts And FAP_NISA_FORUM%)<>0 Then CaptureLine "NISA Forum" If (FAPconfig.wRestrictions And FAP_NO_PRIVATE_MSGS%)<>0 Then CaptureLine "Private Messages not allowed" Else CaptureLine "Private Messages are allowed" End If CaptureLine "" On Error Resume Next ' Get the message section names for the forum from Compuserve CaptureLine "Message Sections Available:" For i = 0 To UBound(szMsgSection) buf = Str(szMsgSection(i).cId)+" "+szMsgSection(i).lpTitle ReplaceAnyInString buf, "_", " " CaptureLine buf Next CaptureLine "" ' Get the library section names for the forum from Compuserve CaptureLine "Libraries Available:" For i = 0 To UBound(szLibSection) buf = Str(szLibSection(i).cId)+" "+szLibSection(i).lpTitle ReplaceAnyInString buf, "_", " " CaptureLine buf Next FinishCapturing End Sub