Skip to content

Commit cb32dc1

Browse files
committed
Correction in Extraction Events
1 parent dd6b89b commit cb32dc1

File tree

1 file changed

+142
-129
lines changed

1 file changed

+142
-129
lines changed

FabTools/FabZipVo/FabZipFileCtrl.prg

Lines changed: 142 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -6,133 +6,146 @@ USING Ionic.Zip
66

77
BEGIN NAMESPACE FabZip
88

9-
CLASS FabZipFileCtrl INHERIT FixedText
10-
11-
PROTECT oZipFile AS FabZipFile
12-
13-
PROTECT lStartNew AS LOGIC
14-
PROTECT nDone AS DWORD
15-
16-
CONSTRUCTOR(oOwner, xID, oPoint, oDimension, cText)
17-
// Call Super
18-
SUPER(oOwner, xID, oPoint, oDimension, cText)
19-
//
20-
SELF:oZipFile := FabZipFile{ NULL_STRING , SELF }
21-
SELF:oZipFile:ExtractHandler := EventHandler<ExtractProgressEventArgs>{SELF, @ExtractHandler() }
22-
SELF:oZipFile:SaveHandler := EventHandler<SaveProgressEventArgs>{ SELF, @SaveHandler() }
23-
SELF:lStartNew := FALSE
24-
//
25-
SELF:Hide()
26-
RETURN
27-
28-
ACCESS ZipFile AS FabZipFile
29-
RETURN SELF:oZipFile
30-
31-
PRIVATE METHOD ExtractHandler( sender AS System.Object, e AS ExtractProgressEventArgs ) AS System.Void
32-
//local Params as Usual[]
33-
LOCAL symEvent AS SYMBOL
34-
LOCAL cFile AS STRING
35-
LOCAL nSize AS INT64
36-
//
37-
symEvent := NULL_SYMBOL
38-
cFile := ""
39-
nSize := 0
40-
//
41-
IF ( SELF:Owner != NULL )
42-
//
43-
SWITCH e:EventType
44-
CASE ZipProgressEventType.Extracting_BeforeExtractEntry
45-
symEvent := #new
46-
cFile := e:CurrentEntry:FileName
47-
nSize := e:CurrentEntry:UncompressedSize
48-
CASE ZipProgressEventType.Extracting_AfterExtractEntry
49-
symEvent := #end
50-
cFile := ""
51-
nSize := 0
52-
CASE ZipProgressEventType.Extracting_EntryBytesWritten
53-
symEvent := #Update
54-
cFile := ""
55-
nSize := e:BytesTransferred
56-
OTHERWISE
57-
RETURN
58-
END SWITCH
59-
//
60-
//Params := <Usual>{ self, symEvent, cFile, nSize }
61-
//
62-
Send( SELF:Owner, "OnFabZipProgress", SELF, symEvent, cFile, nSize )
63-
//ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", Params )
64-
ENDIF
65-
RETURN
66-
67-
PRIVATE METHOD SaveHandler( sender AS System.Object, e AS SaveProgressEventArgs ) AS System.Void
68-
LOCAL zipParams AS OBJECT[]
69-
LOCAL symEvent AS SYMBOL
70-
LOCAL cFile AS STRING
71-
LOCAL nSize AS INT64
72-
//
73-
symEvent := NULL_SYMBOL
74-
cFile := ""
75-
nSize := 0
76-
//
77-
IF ( SELF:Owner != NULL )
78-
//
79-
SWITCH e:EventType
80-
CASE ZipProgressEventType.Saving_BeforeWriteEntry
81-
// We will need to send two notifications on first Update
82-
SELF:lStartNew := TRUE
83-
//symEvent := #new
84-
//cFile := e:CurrentEntry:FileName
85-
//nSize := e:CurrentEntry:UncompressedSize
86-
CASE ZipProgressEventType.Saving_AfterWriteEntry
87-
symEvent := #end
88-
cFile := ""
89-
nSize := 0
90-
SELF:lStartNew := FALSE // UnNeeded
91-
CASE ZipProgressEventType.Saving_EntryBytesRead
92-
IF ( SELF:lStartNew )
93-
//
94-
symEvent := #new
95-
cFile := e:CurrentEntry:FileName
96-
nSize := e:TotalBytesToTransfer
97-
zipParams := <OBJECT>{ SELF, symEvent, cFile, nSize }
98-
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", zipParams )
99-
SELF:lStartNew := FALSE
100-
SELF:nDone := 0
101-
ENDIF
102-
symEvent := #Update
103-
cFile := ""
104-
nSize := e:BytesTransferred - SELF:nDone
105-
SELF:nDone := e:BytesTransferred
106-
OTHERWISE
107-
RETURN
108-
END SWITCH
109-
//
110-
zipParams := <OBJECT>{ SELF, symEvent, cFile, nSize }
111-
//
112-
//Send( Self:Owner, "OnFabZipProgress", Self, symEvent, cFile, nSize )
113-
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", zipParams )
114-
ENDIF
115-
RETURN
116-
117-
METHOD OnFabOperationSize( nTotalFiles AS INT64, nTotalSize AS INT64 ) AS VOID
118-
//
119-
IF ( SELF:Owner != NULL )
120-
//
121-
Send( SELF:Owner, "OnFabZipProgress", SELF, #TotalFiles, "", nTotalFiles )
122-
//
123-
Send( SELF:Owner, "OnFabZipProgress", SELF, #TotalSize, "", nTotalSize )
124-
ENDIF
125-
RETURN
126-
127-
METHOD OnFabZipDirUpdate( ) AS VOID
128-
LOCAL zipParams AS OBJECT[]
129-
//
130-
zipParams := <OBJECT>{ SELF }
131-
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipDirUpdate", zipParams )
132-
//
133-
RETURN
134-
135-
136-
END CLASS
137-
9+
CLASS FabZipFileCtrl INHERIT FixedText
10+
11+
PROTECT oZipFile AS FabZipFile
12+
13+
PROTECT lStartNew AS LOGIC
14+
PROTECT nDone AS DWORD
15+
16+
CONSTRUCTOR(oOwner, xID, oPoint, oDimension, cText)
17+
// Call Super
18+
SUPER(oOwner, xID, oPoint, oDimension, cText)
19+
//
20+
SELF:oZipFile := FabZipFile{ NULL_STRING , SELF }
21+
SELF:oZipFile:ExtractHandler := EventHandler<ExtractProgressEventArgs>{SELF, @ExtractHandler() }
22+
SELF:oZipFile:SaveHandler := EventHandler<SaveProgressEventArgs>{ SELF, @SaveHandler() }
23+
SELF:lStartNew := FALSE
24+
//
25+
SELF:Hide()
26+
RETURN
27+
28+
ACCESS ZipFile AS FabZipFile
29+
RETURN SELF:oZipFile
30+
31+
PRIVATE METHOD ExtractHandler( sender AS System.Object, e AS ExtractProgressEventArgs ) AS System.Void
32+
//local Params as Usual[]
33+
LOCAL zipParams AS OBJECT[]
34+
LOCAL symEvent AS SYMBOL
35+
LOCAL cFile AS STRING
36+
LOCAL nSize AS INT64
37+
//
38+
symEvent := NULL_SYMBOL
39+
cFile := ""
40+
nSize := 0
41+
//
42+
IF ( SELF:Owner != NULL )
43+
//
44+
SWITCH e:EventType
45+
CASE ZipProgressEventType.Extracting_BeforeExtractEntry
46+
self:lStartNew := true
47+
// symEvent := #new
48+
// cFile := e:CurrentEntry:FileName
49+
// nSize := e:CurrentEntry:UncompressedSize
50+
CASE ZipProgressEventType.Extracting_AfterExtractEntry
51+
symEvent := #end
52+
cFile := ""
53+
nSize := 0
54+
CASE ZipProgressEventType.Extracting_EntryBytesWritten
55+
IF ( SELF:lStartNew )
56+
//
57+
symEvent := #new
58+
cFile := e:CurrentEntry:FileName
59+
nSize := e:TotalBytesToTransfer
60+
zipParams := <OBJECT>{ SELF, symEvent, cFile, nSize }
61+
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", zipParams )
62+
SELF:lStartNew := FALSE
63+
SELF:nDone := 0
64+
ENDIF
65+
symEvent := #Update
66+
cFile := ""
67+
nSize := e:BytesTransferred - SELF:nDone
68+
SELF:nDone := e:BytesTransferred
69+
OTHERWISE
70+
RETURN
71+
END SWITCH
72+
//
73+
//Params := <Usual>{ self, symEvent, cFile, nSize }
74+
//
75+
Send( SELF:Owner, "OnFabZipProgress", SELF, symEvent, cFile, nSize )
76+
//ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", Params )
77+
ENDIF
78+
RETURN
79+
80+
PRIVATE METHOD SaveHandler( sender AS System.Object, e AS SaveProgressEventArgs ) AS System.Void
81+
LOCAL zipParams AS OBJECT[]
82+
LOCAL symEvent AS SYMBOL
83+
LOCAL cFile AS STRING
84+
LOCAL nSize AS INT64
85+
//
86+
symEvent := NULL_SYMBOL
87+
cFile := ""
88+
nSize := 0
89+
//
90+
IF ( SELF:Owner != NULL )
91+
//
92+
SWITCH e:EventType
93+
CASE ZipProgressEventType.Saving_BeforeWriteEntry
94+
// We will need to send two notifications on first Update
95+
SELF:lStartNew := TRUE
96+
//symEvent := #new
97+
//cFile := e:CurrentEntry:FileName
98+
//nSize := e:CurrentEntry:UncompressedSize
99+
CASE ZipProgressEventType.Saving_AfterWriteEntry
100+
symEvent := #end
101+
cFile := ""
102+
nSize := 0
103+
SELF:lStartNew := FALSE // UnNeeded
104+
CASE ZipProgressEventType.Saving_EntryBytesRead
105+
IF ( SELF:lStartNew )
106+
//
107+
symEvent := #new
108+
cFile := e:CurrentEntry:FileName
109+
nSize := e:TotalBytesToTransfer
110+
zipParams := <OBJECT>{ SELF, symEvent, cFile, nSize }
111+
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", zipParams )
112+
SELF:lStartNew := FALSE
113+
SELF:nDone := 0
114+
ENDIF
115+
symEvent := #Update
116+
cFile := ""
117+
nSize := e:BytesTransferred - SELF:nDone
118+
SELF:nDone := e:BytesTransferred
119+
OTHERWISE
120+
RETURN
121+
END SWITCH
122+
//
123+
zipParams := <OBJECT>{ SELF, symEvent, cFile, nSize }
124+
//
125+
//Send( Self:Owner, "OnFabZipProgress", Self, symEvent, cFile, nSize )
126+
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipProgress", zipParams )
127+
ENDIF
128+
RETURN
129+
130+
METHOD OnFabOperationSize( nTotalFiles AS INT64, nTotalSize AS INT64 ) AS VOID
131+
//
132+
IF ( SELF:Owner != NULL )
133+
//
134+
Send( SELF:Owner, "OnFabZipProgress", SELF, #TotalFiles, "", nTotalFiles )
135+
//
136+
Send( SELF:Owner, "OnFabZipProgress", SELF, #TotalSize, "", nTotalSize )
137+
ENDIF
138+
RETURN
139+
140+
METHOD OnFabZipDirUpdate( ) AS VOID
141+
LOCAL zipParams AS OBJECT[]
142+
//
143+
zipParams := <OBJECT>{ SELF }
144+
ReflectionLib.InvokeMethod( SELF:Owner, "OnFabZipDirUpdate", zipParams )
145+
//
146+
RETURN
147+
148+
149+
END CLASS
150+
138151
END NAMESPACE // FabZip

0 commit comments

Comments
 (0)