Initial revision
[citadel.git] / wincit / download.frm
1 VERSION 4.00
2 Begin VB.Form Download 
3    Appearance      =   0  'Flat
4    BackColor       =   &H00C0C0C0&
5    BorderStyle     =   3  'Fixed Dialog
6    Caption         =   "Download..."
7    ClientHeight    =   3120
8    ClientLeft      =   4140
9    ClientTop       =   3630
10    ClientWidth     =   5610
11    ControlBox      =   0   'False
12    BeginProperty Font 
13       name            =   "MS Sans Serif"
14       charset         =   0
15       weight          =   700
16       size            =   8.25
17       underline       =   0   'False
18       italic          =   0   'False
19       strikethrough   =   0   'False
20    EndProperty
21    ForeColor       =   &H80000008&
22    Height          =   3525
23    Left            =   4080
24    LinkTopic       =   "Form1"
25    MaxButton       =   0   'False
26    MDIChild        =   -1  'True
27    MinButton       =   0   'False
28    ScaleHeight     =   3120
29    ScaleWidth      =   5610
30    Top             =   3285
31    Width           =   5730
32    Begin Threed.SSPanel info 
33       Height          =   495
34       Left            =   1200
35       TabIndex        =   5
36       Top             =   1320
37       Width           =   4335
38       _Version        =   65536
39       _ExtentX        =   7646
40       _ExtentY        =   873
41       _StockProps     =   15
42       Caption         =   "info"
43       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
44          name            =   "MS Sans Serif"
45          charset         =   0
46          weight          =   400
47          size            =   12
48          underline       =   0   'False
49          italic          =   0   'False
50          strikethrough   =   0   'False
51       EndProperty
52       BevelWidth      =   4
53       BorderWidth     =   5
54       BevelOuter      =   1
55    End
56    Begin GaugeLib.Gauge progress 
57       Height          =   255
58       Left            =   240
59       TabIndex        =   4
60       Top             =   2040
61       Width           =   5175
62       _Version        =   65536
63       _ExtentX        =   9128
64       _ExtentY        =   450
65       _StockProps     =   73
66       Autosize        =   -1  'True
67       NeedleWidth     =   1
68    End
69    Begin VB.CommandButton start_button 
70       Appearance      =   0  'Flat
71       BackColor       =   &H80000005&
72       Caption         =   "&Start download"
73       BeginProperty Font 
74          name            =   "MS Sans Serif"
75          charset         =   0
76          weight          =   400
77          size            =   9.75
78          underline       =   0   'False
79          italic          =   0   'False
80          strikethrough   =   0   'False
81       EndProperty
82       Height          =   495
83       Left            =   2280
84       TabIndex        =   3
85       Top             =   2520
86       Width           =   1815
87    End
88    Begin Threed.SSPanel DestFile 
89       Height          =   495
90       Left            =   1200
91       TabIndex        =   2
92       Top             =   720
93       Width           =   4335
94       _Version        =   65536
95       _ExtentX        =   7646
96       _ExtentY        =   873
97       _StockProps     =   15
98       Caption         =   "DestFile"
99       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
100          name            =   "MS Sans Serif"
101          charset         =   0
102          weight          =   400
103          size            =   12
104          underline       =   0   'False
105          italic          =   0   'False
106          strikethrough   =   0   'False
107       EndProperty
108       BevelWidth      =   4
109       BorderWidth     =   5
110       BevelOuter      =   1
111    End
112    Begin Threed.SSPanel SourceFile 
113       Height          =   495
114       Left            =   1200
115       TabIndex        =   1
116       Top             =   120
117       Width           =   4335
118       _Version        =   65536
119       _ExtentX        =   7646
120       _ExtentY        =   873
121       _StockProps     =   15
122       Caption         =   "SourceFile"
123       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
124          name            =   "MS Sans Serif"
125          charset         =   0
126          weight          =   400
127          size            =   12
128          underline       =   0   'False
129          italic          =   0   'False
130          strikethrough   =   0   'False
131       EndProperty
132       BevelWidth      =   4
133       BorderWidth     =   5
134       BevelOuter      =   1
135    End
136    Begin VB.CommandButton cancel_button 
137       Appearance      =   0  'Flat
138       BackColor       =   &H80000005&
139       Caption         =   "&Cancel"
140       BeginProperty Font 
141          name            =   "MS Sans Serif"
142          charset         =   0
143          weight          =   400
144          size            =   9.75
145          underline       =   0   'False
146          italic          =   0   'False
147          strikethrough   =   0   'False
148       EndProperty
149       Height          =   492
150       Left            =   4200
151       TabIndex        =   0
152       Top             =   2520
153       Width           =   1332
154    End
155    Begin Threed.SSPanel Panel3D1 
156       Height          =   495
157       Left            =   120
158       TabIndex        =   9
159       Top             =   1920
160       Width           =   5415
161       _Version        =   65536
162       _ExtentX        =   9551
163       _ExtentY        =   873
164       _StockProps     =   15
165       BevelWidth      =   4
166       BorderWidth     =   5
167       BevelOuter      =   1
168    End
169    Begin MSComDlg.CommonDialog SaveAs 
170       Left            =   1680
171       Top             =   2520
172       _Version        =   65536
173       _ExtentX        =   847
174       _ExtentY        =   847
175       _StockProps     =   0
176       DialogTitle     =   "Save As..."
177       InitDir         =   "C:\"
178    End
179    Begin VB.Label Label3 
180       Appearance      =   0  'Flat
181       AutoSize        =   -1  'True
182       BackColor       =   &H80000005&
183       BackStyle       =   0  'Transparent
184       Caption         =   "Info"
185       BeginProperty Font 
186          name            =   "MS Sans Serif"
187          charset         =   0
188          weight          =   400
189          size            =   12
190          underline       =   0   'False
191          italic          =   0   'False
192          strikethrough   =   0   'False
193       EndProperty
194       ForeColor       =   &H80000008&
195       Height          =   300
196       Left            =   120
197       TabIndex        =   8
198       Top             =   1440
199       Width           =   420
200    End
201    Begin VB.Label Label2 
202       Appearance      =   0  'Flat
203       AutoSize        =   -1  'True
204       BackColor       =   &H80000005&
205       BackStyle       =   0  'Transparent
206       Caption         =   "Save As:"
207       BeginProperty Font 
208          name            =   "MS Sans Serif"
209          charset         =   0
210          weight          =   400
211          size            =   12
212          underline       =   0   'False
213          italic          =   0   'False
214          strikethrough   =   0   'False
215       EndProperty
216       ForeColor       =   &H80000008&
217       Height          =   300
218       Left            =   120
219       TabIndex        =   7
220       Top             =   840
221       Width           =   945
222    End
223    Begin VB.Label Label1 
224       Appearance      =   0  'Flat
225       BackColor       =   &H80000005&
226       BackStyle       =   0  'Transparent
227       Caption         =   "Source:"
228       BeginProperty Font 
229          name            =   "MS Sans Serif"
230          charset         =   0
231          weight          =   400
232          size            =   12
233          underline       =   0   'False
234          italic          =   0   'False
235          strikethrough   =   0   'False
236       EndProperty
237       ForeColor       =   &H80000008&
238       Height          =   255
239       Left            =   120
240       TabIndex        =   6
241       Top             =   240
242       Width           =   975
243    End
244 End
245 Attribute VB_Name = "Download"
246 Attribute VB_Creatable = False
247 Attribute VB_Exposed = False
248 Dim InProgress%
249 Dim Cancelled%
250
251 Private Sub cancel_button_Click()
252     
253 If InProgress% = 1 Then
254     Cancelled% = 1
255 Else
256     Unload Download
257     Load RoomPrompt
258     End If
259
260 End Sub
261
262 Private Sub Form_Load()
263
264
265     Show
266     Download.WindowState = 0
267     Download.Top = Int((MainWin.Height - Download.Height) / 3)
268     Download.Left = Int((MainWin.Width - Download.Width) / 2)
269     
270     SourceFile.Caption = DownLoadFileName$
271
272     SaveAs.filename = DownLoadFileName$
273     SaveAs.Action = 2
274
275     DestFile.Caption = SaveAs.filename
276     
277
278
279 End Sub
280
281 Private Sub start_button_Click()
282
283 If begin_trans() = True Then
284     Info.Caption = "Sending server command"
285     
286     serv_puts ("OPEN " + DownLoadFileName$)
287     a$ = serv_gets()
288     Info.Caption = a$
289
290     If Left$(a$, 1) <> "2" Then
291         FileLength& = (-1)
292     Else
293         FileLength& = Val(extract$(Right$(a$, Len(a$) - 4), 0))
294         End If
295
296     Info.Caption = "File len is " + Str$(FileLength&)
297     Call end_trans
298     End If
299
300 If FileLength& < 0 Then
301     MsgBox Right$(a$, Len(a$) - 4), 16, "Error"
302     Unload Download
303     Load RoomPrompt
304     End If
305
306 InProgress% = 1
307 Open DestFile.Caption For Output As #1
308 start_button.Enabled = False
309 start_button.Visible = False
310
311 Progress.min = 0
312 Progress.Max = FileLength& / 1024
313
314 GotBytes& = 0
315 Do While GotBytes& < FileLength&
316     If Cancelled% = 1 Then GoTo ENDOFXFER
317     NeedBytes& = 4096
318     If (FileLength& - GotBytes&) < 4096 Then NeedBytes& = FileLength& - GotBytes&
319     If begin_trans() = True Then
320         serv_puts ("READ " + Str$(GotBytes&) + "|" + Str$(NeedBytes&))
321         a$ = serv_gets()
322         If Left$(a$, 1) = "6" Then
323             b$ = serv_read(CInt(NeedBytes&))
324             GotBytes& = GotBytes& + NeedBytes&
325             Print #1, b$;
326             End If
327         Call end_trans
328         End If
329     Progress.Value = GotBytes& / 1024
330     Info.Caption = "Received " + Str$(GotBytes&) + " of " + Str$(FileLength&) + " bytes"
331     DoEvents
332     Loop
333
334 ENDOFXFER:
335 Close #1
336 If begin_trans() = True Then
337     serv_puts ("CLOS")
338     a$ = serv_gets()
339     cancel_button.Caption = "&OK!"
340     InProgress% = 0
341     Call end_trans
342     End If
343
344 End Sub
345