More QWK net updates

This commit is contained in:
mysticbbs 2013-09-07 23:02:25 -04:00
parent 228e261c93
commit bb924941ec
3 changed files with 118 additions and 27 deletions

View File

@ -634,7 +634,7 @@ Var
S : String; S : String;
A : SmallInt; A : SmallInt;
Begin Begin
If (MBase.NetType > 0) and (MBase.NetType <> 3) Then Begin If (MBase.NetType > 0) and (MBase.NetType <> 3) and (MBase.QwkNetID = 0) Then Begin
Msg^.DoStringLn (#1 + 'MSGID: ' + strAddr2Str(bbsCfg.NetAddress[MBase.NetAddr]) + ' ' + strI2H(CurDateDos, 8)); Msg^.DoStringLn (#1 + 'MSGID: ' + strAddr2Str(bbsCfg.NetAddress[MBase.NetAddr]) + ' ' + strI2H(CurDateDos, 8));
If ReplyID <> '' Then If ReplyID <> '' Then
@ -663,7 +663,13 @@ Begin
If MBase.NetType > 0 Then Begin If MBase.NetType > 0 Then Begin
Msg^.DoStringLn (#13 + '--- ' + mysSoftwareID + ' v' + mysVersion + ' (' + OSID + ')'); Msg^.DoStringLn (#13 + '--- ' + mysSoftwareID + ' v' + mysVersion + ' (' + OSID + ')');
Msg^.DoStringLn (' * Origin: ' + ResolveOrigin(MBase) + ' (' + strAddr2Str(Msg^.GetOrigAddr) + ')');
S := ' * Origin: ' + ResolveOrigin(MBase);
If MBase.QwkNetID = 0 Then
S := S + ' (' + strAddr2Str(Msg^.GetOrigAddr) + ')';
Msg^.DoStringLn (S);
End; End;
End; End;

View File

@ -471,7 +471,7 @@ Begin
Else Else
Temp := 'messages.dat'; Temp := 'messages.dat';
DataFile := TFileBuffer.Create(4 * 1024); DataFile := TFileBuffer.Create(16 * 1024);
DataFile.OpenStream (WorkPath + Temp, 1, fmCreate, fmRWDN); DataFile.OpenStream (WorkPath + Temp, 1, fmCreate, fmRWDN);
@ -565,7 +565,7 @@ Begin
Else Else
Line := PacketID + '.msg'; Line := PacketID + '.msg';
DataFile := TFileBuffer.Create(4 * 1024); DataFile := TFileBuffer.Create(16 * 1024);
If Not DataFile.OpenStream (FileFind(WorkPath + Line), 1, fmOpen, fmRWDN) Then Begin If Not DataFile.OpenStream (FileFind(WorkPath + Line), 1, fmOpen, fmRWDN) Then Begin
DataFile.Free; DataFile.Free;
@ -588,6 +588,8 @@ Begin
Exit; Exit;
End; End;
MsgBase := NIL;
While Not DataFile.EOF Do Begin While Not DataFile.EOF Do Begin
DataFile.ReadBlock(QwkHeader, SizeOf(QwkHeader)); DataFile.ReadBlock(QwkHeader, SizeOf(QwkHeader));
@ -596,14 +598,36 @@ Begin
Chunks := strS2I(QwkBlock) - 1; Chunks := strS2I(QwkBlock) - 1;
If IsNetworked Then If IsNetworked Then Begin
BaseFound := GetMBaseByQwkID (UserRecord.QwkNetwork, QwkHeader.ConfNum, MBase) If (MBase.QwkNetID = UserRecord.QwkNetwork) And (MBase.QwkConfID = QwkHeader.ConfNum) Then
// when polling userrecord.qwknetwork needs to be set to qwknetwork ID BaseFound := True
Else Else Begin
BaseFound := GetMBaseByIndex (QwkHeader.ConfNum, MBase); BaseFound := GetMBaseByQwkID (UserRecord.QwkNetwork, QwkHeader.ConfNum, MBase);
If BaseFound and (MsgBase <> NIL) Then Begin
MsgBase^.CloseMsgBase;
Dispose (MsgBase, Done);
MsgBase := NIL;
End;
End;
End Else Begin
If MBase.Index = QwkHeader.ConfNum Then
BaseFound := True
Else Begin
BaseFound := GetMBaseByIndex (QwkHeader.ConfNum, MBase);
If BaseFound and (MsgBase <> NIL) Then Begin
MsgBase^.CloseMsgBase;
Dispose (MsgBase, Done);
MsgBase := NIL;
End;
End;
End;
If MsgBase = NIL Then
BaseFound := MBaseOpenCreate(MsgBase, MBase, WorkPath);
If BaseFound Then Begin If BaseFound Then Begin
If MBaseOpenCreate(MsgBase, MBase, WorkPath) Then Begin
MBaseAssignData(UserRecord, MsgBase, MBase); MBaseAssignData(UserRecord, MsgBase, MBase);
@ -624,10 +648,10 @@ Begin
Move (QwkHeader.Subject, QwkBlock[1], 25); Move (QwkHeader.Subject, QwkBlock[1], 25);
MsgBase^.SetSubj(strStripR(QwkBlock, ' ')); MsgBase^.SetSubj(strStripR(QwkBlock, ' '));
Move (QwkHeader.ReferNum, QwkBlock[1], 6); // Move (QwkHeader.ReferNum, QwkBlock[1], 6);
QwkBlock[0] := #6; // QwkBlock[0] := #6;
MsgBase^.SetRefer(strS2I(strStripR(QwkBlock, ' '))); // MsgBase^.SetRefer(strS2I(strStripR(QwkBlock, ' ')));
Line := ''; Line := '';
LineCount := 0; LineCount := 0;
@ -686,17 +710,19 @@ Begin
If Not IsNetworked Then If Not IsNetworked Then
If MBase.NetType > 0 Then Begin If MBase.NetType > 0 Then Begin
MsgBase^.DoStringLn (#13 + '--- ' + mysSoftwareID + '/QWK v' + mysVersion + ' (' + OSID + ')'); MsgBase^.DoStringLn (#13 + '--- ' + mysSoftwareID + '/QWK v' + mysVersion + ' (' + OSID + ')');
MsgBase^.DoStringLn (' * Origin: ' + GetOriginLine(MBase) + ' (' + Addr2Str(MsgBase^.GetOrigAddr) + ')');
MsgBase^.DoStringLn (' * Origin: ' + GetOriginLine(MBase) + ' (' + Addr2Str(MsgBase^.GetOrigAddr) + ')');
End; End;
If Not IsControl Then Begin If Not IsControl Then Begin
// ISQWK = a node importing from HUB // ISQWK = a node importing from HUB
If ((IsQwk) or (HasAccess(Self, MBase.PostACS))) and If (IsQwk) or (HasAccess(Self, MBase.PostACS)) Then Begin
((IsNetworked And (UserRecord.QwkNetwork = MBase.QwkNetID)) or (Not IsNetworked)) Then Begin
// If ((IsQwk) or (HasAccess(Self, MBase.PostACS))) and
// ((IsNetworked And (UserRecord.QwkNetwork = MBase.QwkNetID)) or (Not IsNetworked)) Then Begin
If IsNetworked And Not IsQWK Then If IsNetworked And Not IsQWK Then
MsgBase^.DoStringLn (#1'QSRC ' + PacketID); MsgBase^.DoStringLn (#1'QSRC ' + PacketID);
// ^^ needs to change to UserRecord.Handle
MsgBase^.WriteMsg; MsgBase^.WriteMsg;
@ -704,16 +730,6 @@ Begin
End Else End Else
Inc (RepFailed); Inc (RepFailed);
End; End;
MsgBase^.CloseMsgBase;
Dispose (MsgBase, Done);
End Else Begin
Inc (RepFailed);
For Count1 := 1 to Chunks Do
DataFile.ReadBlock (QwkBlock[1], 128);
End;
End Else Begin End Else Begin
Inc (RepFailed); Inc (RepFailed);
@ -724,6 +740,11 @@ Begin
DataFile.Free; DataFile.Free;
If MsgBase <> NIL Then Begin
MsgBase^.CloseMsgBase;
Dispose (MsgBase, Done);
End;
Assign (ExtFile, FileFind(WorkPath + 'todoor.ext')); Assign (ExtFile, FileFind(WorkPath + 'todoor.ext'));
{$I-} Reset (ExtFile); {$I+} {$I-} Reset (ExtFile); {$I+}

View File

@ -3,6 +3,10 @@ Program QwkPoll;
{$I M_OPS.PAS} {$I M_OPS.PAS}
Uses Uses
{$IFDEF DEBUG}
HeapTrc,
LineInfo,
{$ENDIF}
m_DateTime, m_DateTime,
m_Strings, m_Strings,
m_FileIO, m_FileIO,
@ -28,6 +32,8 @@ Begin
WriteLn ('- Exchanging Mail for ' + QwkNet.Description); WriteLn ('- Exchanging Mail for ' + QwkNet.Description);
DirClean (TempPath, '');
User.Handle := QwkNet.PacketID; User.Handle := QwkNet.PacketID;
User.QwkNetwork := QwkNet.Index; User.QwkNetwork := QwkNet.Index;
@ -43,6 +49,9 @@ Begin
WriteLn (' - Exported @' + QwkNet.PacketID + '.rep -> ', QWK.TotalMessages, ' msgs '); WriteLn (' - Exported @' + QwkNet.PacketID + '.rep -> ', QWK.TotalMessages, ' msgs ');
WriteLn (' - Connecting via FTP to ' + QWkNet.HostName); WriteLn (' - Connecting via FTP to ' + QWkNet.HostName);
If QWK.TotalMessages = 0 Then
DirClean (TempPath, '');
FTP := TFTPClient.Create(bbsCfg.inetInterface); FTP := TFTPClient.Create(bbsCfg.inetInterface);
If FTP.OpenConnection(QwkNet.HostName) Then Begin If FTP.OpenConnection(QwkNet.HostName) Then Begin
@ -78,6 +87,57 @@ Begin
WriteLn; WriteLn;
End; End;
Procedure ImportPacket (QwkNet: RecQwkNetwork; Path: String);
Var
QWK : TQwkEngine;
User : RecUser;
Begin
WriteLn ('- Importing ' + Path + QwkNet.PacketID + '.qwk');
ExecuteArchive (TempPath, Path + QwkNet.PacketID + '.qwk', QwkNet.ArcType, '*', 2);
User.Handle := QwkNet.PacketID;
User.QwkNetwork := QwkNet.Index;
QWK := TQwkEngine.Create (TempPath, QwkNet.PacketID, 1, User);
QWK.IsNetworked := True;
QWK.IsExtended := QwkNet.UseQWKE;
QWK.ImportPacket(True);
WriteLn (' - Imported ', QWK.RepOK, ' messages (', QWK.RepFailed, ' failed)');
QWK.Free;
End;
Procedure ExportPacket (QwkNet: RecQwkNetwork; Path: String);
Var
QWK : TQwkEngine;
User : RecUser;
Begin
WriteLn ('- Exporting ' + Path + QwkNet.PacketID + '.rep');
User.Handle := QwkNet.PacketID;
User.QwkNetwork := QwkNet.Index;
QWK := TQwkEngine.Create (TempPath, QwkNet.PacketID, 1, User);
QWK.IsNetworked := True;
QWK.IsExtended := QwkNet.UseQWKE;
QWK.ExportPacket(True);
If QWK.TotalMessages > 0 Then
ExecuteArchive (TempPath, Path + QwkNet.PacketID + '.rep', QwkNet.ArcType, TempPath + '*', 1);
DirClean (TempPath, '');
WriteLn (' - Exported ', QWK.TotalMessages, ' messages');
QWK.Free;
End;
Var Var
Str : String; Str : String;
F : File; F : File;
@ -123,6 +183,8 @@ Begin
Case Mode of Case Mode of
0 : If PollByQwkNet(QwkNet) Then 0 : If PollByQwkNet(QwkNet) Then
Inc (Count); Inc (Count);
1 : ExportPacket(QwkNet, DirSlash(ParamStr(3)));
2 : ImportPacket(QwkNet, DirSlash(ParamStr(3)));
End; End;
End; End;
@ -134,6 +196,8 @@ Begin
Case Mode of Case Mode of
0 : If PollByQwkNet(QwkNet) Then 0 : If PollByQwkNet(QwkNet) Then
Inc (Count); Inc (Count);
1 : ExportPacket(QwkNet, DirSlash(ParamStr(3)));
2 : ImportPacket(QwkNet, DirSlash(ParamStr(3)));
End; End;
End Else Begin End Else Begin
WriteLn ('Invalid command line.'); WriteLn ('Invalid command line.');