Subversion Repositories Kolibri OS

Rev

Rev 2712 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2712 Rev 2713
Line -... Line 1...
-
 
1
; version:      0.6
-
 
2
; last update:  01/06/2012
-
 
3
; written by:   Lipatov Kirill aka Leency
-
 
4
; changes:      removed old code
-
 
5
;               added edit_box
-
 
6
;               using system colors
-
 
7
;-----------------------------------------------------------
1
; version: 0.5
8
; version:      0.5
2
; last update:  07/10/2010
9
; date:         07/10/2010
3
; written by:   Marat Zakiyanov aka Mario79, aka Mario
10
; written by:   Marat Zakiyanov aka Mario79, aka Mario
4
; changes:      reducing the size of the binary code,
11
; changes:      reducing the size of the binary code,
5
;               program uses far less memory while running
12
;               program uses far less memory while running
6
;               (>0x7000, the old version used >0x100000),
13
;               (>0x7000, the old version used >0x100000),
7
;               process only net event at start with parameter
14
;               process only net event at start with parameter
8
;-----------------------------------------------------------
15
;-----------------------------------------------------------
9
; version 0.3 -0.4 
16
; version:      0.3 -0.4 
10
; written by:   CleverMouse
17
; written by:   CleverMouse
11
;
18
;
12
;-----------------------------------------------------------
19
;-----------------------------------------------------------
13
; wget 0.2 by barsuk
20
; wget 0.2 by barsuk
14
; based on Menuet Httpc
21
; based on Menuet Httpc
Line -... Line 22...
-
 
22
 
-
 
23
 
-
 
24
;TODO
-
 
25
;downloading status indication in window
15
 
26
 
16
 
27
 
17
; Enabling debugging puts stuff to the debug board
28
; Enabling debugging puts stuff to the debug board
18
DEBUGGING_ENABLED	equ 1
29
DEBUGGING_ENABLED	equ 1
Line 30... Line 41...
30
	dd params	; I_PARAM
41
	dd params	; I_PARAM
31
	dd 0x0		; I_Path
42
	dd 0x0		; I_Path
Line 32... Line 43...
32
 
43
 
33
include	'lang.inc'
44
include	'lang.inc'
34
include	'../../../macros.inc'
45
include	'../../../macros.inc'
-
 
46
include	'../../../proc32.inc'
-
 
47
include '../../../develop/libraries/box_lib/load_lib.mac'
35
include	"../../../proc32.inc"
48
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
36
include	"dll.inc"
49
include	'dll.inc'
Line 37... Line 50...
37
include	"debug.inc"
50
include	'debug.inc'
Line 38... Line 51...
38
 
51
 
Line -... Line 52...
-
 
52
URLMAXLEN	equ 256	; maximum length of url string
-
 
53
 
-
 
54
primary_buffer_size	equ 4096
-
 
55
 
39
URLMAXLEN	equ 256	; maximum length of url string
56
sc system_colors
40
 
57
 
Line 41... Line 58...
41
primary_buffer_size	equ 4096
58
@use_library
42
 
59
 
43
; Memory usage
60
; Memory usage
-
 
61
; webpage headers at buf_headers
-
 
62
 
-
 
63
START:	; start of execution
-
 
64
;dps	<"Program started",13,10>
-
 
65
; prepare webAddr area	
-
 
66
	load_libraries l_libs_start,l_libs_end
-
 
67
	mov	ebp,lib_0
44
; webpage headers at buf_headers
68
	cmp	dword [ebp+ll_struc_size-4],0
45
 
69
	jz	@f
46
START:	; start of execution
70
		mcall -1 ;exit not correct
47
;dps	<"Program started",13,10>
71
	@@:
48
; prepare webAddr area	
72
 
Line 67... Line 91...
67
 
91
 
68
	call	load_settings
92
	call	load_settings
69
	cmp	[params],byte 0
93
	cmp	[params],byte 0
Line -... Line 94...
-
 
94
	jz	prepare_event	;red
70
	jz	prepare_event	;red
95
 
Line 71... Line 96...
71
 
96
 
72
	mcall	40,10000000b ; only net event!!!
97
	mcall 40, 10000000b ; only net event!!!
73
 
98
 
Line 105... Line 130...
105
	jmp	still
130
	jmp	still
Line 106... Line 131...
106
 
131
 
107
prepare_event:
132
prepare_event:
108
; Report events
133
; Report events
109
; Stack 8 + defaults
134
; Stack 8 + defaults
Line 110... Line 135...
110
	mcall	40,10000111b
135
	mcall 40,10100111b
111
 
136
 
Line 112... Line 137...
112
red:	; redraw
137
red:	; redraw
Line 121... Line 146...
121
	je	key
146
	je	key
Line 122... Line 147...
122
 
147
 
123
	cmp	eax,3	; button in buffer ?
148
	cmp	eax,3	; button in buffer ?
Line -... Line 149...
-
 
149
	je	button
-
 
150
	
-
 
151
	cmp  eax,6  ; mouse in buffer ? 
-
 
152
    je	 mouse
124
	je	button
153
 
125
 
154
 
126
; Get the web page data from the remote server
155
; Get the web page data from the remote server
127
	call	read_incoming_data
156
	call	read_incoming_data
128
	mov	eax,[status]
157
	mov	eax,[status]
Line 147... Line 176...
147
	cmp	[status],4	; connection closed by server
176
	cmp	[status],4	; connection closed by server
148
	jbe	no_close	; respond to connection close command
177
	jbe	no_close	; respond to connection close command
149
; draw page
178
; draw page
150
	call	read_incoming_data
179
	call	read_incoming_data
151
	mcall	53,8,[socket]
180
	mcall	53,8,[socket]
152
	call	draw_page
-
 
153
	mov	[onoff],0
181
	mov	[onoff],0
Line 154... Line 182...
154
 
182
 
155
no_close:
183
no_close:
Line 156... Line 184...
156
	jmp	still
184
	jmp	still
157
 
185
 
-
 
186
key:	; key
-
 
187
	mcall	2	; read key
158
key:	; key
188
	stdcall [edit_box_key], dword edit1
159
	mcall	2	; just read it and ignore
189
	
160
	shr	eax,8
190
	shr	eax,8
161
	cmp	eax,184
191
	cmp	eax,184
162
	jne	no_down
192
	jne	no_down
163
	cmp	[display_from],25
193
	cmp	[display_from],25
164
	jb	no_down
-
 
Line 165... Line 194...
165
	sub	[display_from],25
194
	jb	no_down
166
	call	display_page
195
	sub	[display_from],25
167
 
196
 
168
no_down:
197
no_down:
169
	cmp	eax,183
-
 
Line 170... Line 198...
170
	jne	no_up
198
	cmp	eax,183
171
	add	[display_from],25
199
	jne	no_up
Line 172... Line 200...
172
	call	display_page
200
	add	[display_from],25
Line 190... Line 218...
190
 
218
 
191
exit:
219
exit:
192
	or	eax,-1	; close this program
220
	or	eax,-1	; close this program
Line -... Line 221...
-
 
221
	mcall
-
 
222
	
-
 
223
mouse:
-
 
224
	stdcall [edit_box_mouse], edit1
193
	mcall
225
	jmp still
194
 
226
 
195
save:
227
save:
196
dps	"saving"
228
dps	"saving"
197
newline
229
newline
Line 201... Line 233...
201
 
233
 
202
noclose:
234
noclose:
203
	cmp	ah,31
235
	cmp	ah,31
204
	jne	noup
236
	jne	noup
205
	sub	[display_from],20
-
 
206
	call	display_page
237
	sub	[display_from],20
Line 207... Line 238...
207
	jmp	still
238
	jmp	still
208
 
239
 
209
noup:
240
noup:
210
	cmp	ah,32
241
	cmp	ah,32
211
	jne	nodown
-
 
212
	add	[display_from],20
242
	jne	nourl
Line 213... Line -...
213
	call	display_page
-
 
214
	jmp	still
-
 
215
 
-
 
216
nodown:
-
 
217
	cmp	ah,10	; Enter url
-
 
218
	jne	nourl
-
 
219
 
-
 
220
	mov	[addr],dword document_user
-
 
221
	mov	[ya],dword 38
-
 
222
	mov	[len],dword URLMAXLEN
-
 
223
 
-
 
224
	mov	ecx,URLMAXLEN
-
 
225
	mov	edi,[addr]
-
 
226
	mov	al,' '
-
 
227
	rep	stosb
-
 
228
 
-
 
229
	call	print_text
-
 
230
 
243
	add	[display_from],20
231
	mov	edi,[addr]
244
	jmp	still
232
 
245
 
233
f11:
246
f11:
234
	mcall	10
247
	mcall	10
Line 239... Line 252...
239
fbu:
252
fbu:
240
	mcall	2	; get key
253
	mcall	2	; get key
241
	shr	eax,8
254
	shr	eax,8
242
	cmp	eax,8
255
	cmp	eax,8
243
	jnz	nobs
256
	jnz	nobs
244
	cmp	edi,[addr]
-
 
245
	jz	f11
-
 
246
	sub	edi,1
-
 
247
	mov	[edi],byte ' '
-
 
248
	call	print_text
-
 
249
	jmp	f11
257
	jmp	f11
Line 250... Line 258...
250
 
258
 
251
nobs:
259
nobs:
252
	cmp	eax,10
260
	cmp	eax,10
Line 255... Line 263...
255
	je	retkey
263
	je	retkey
Line 256... Line 264...
256
 
264
 
257
	cmp	eax,31
265
	cmp	eax,31
Line 258... Line -...
258
	jbe	f11
-
 
259
 
-
 
260
; Removed in v0.4
-
 
261
;	cmp	eax,95
-
 
262
;	jb	keyok
-
 
263
;	sub	eax,32
-
 
264
 
-
 
265
keyok:
-
 
266
	mov	[edi],al
-
 
267
	call	print_text
-
 
268
	add	edi,1
-
 
269
	mov	esi,[addr]
-
 
270
	add	esi,URLMAXLEN
-
 
271
	cmp	esi,edi
266
	jbe	f11
Line 272... Line 267...
272
	jnz	f11
267
 
273
	jmp	still
268
	jmp	still
Line 768... Line 763...
768
;pregs
763
;pregs
769
	ret
764
	ret
Line 770... Line 765...
770
 
765
 
771
;****************************************************************************
766
;****************************************************************************
772
;    Function
-
 
773
;       draw_page
-
 
774
;
-
 
775
;   Description
-
 
776
;       parses the web page data, storing displayable data at 0x20000
-
 
777
;       and attributes at 0x30000. It then calls display_page to render
-
 
778
;       the data
-
 
779
;
-
 
780
;****************************************************************************
-
 
781
draw_page:
-
 
782
	ret
-
 
783
 
-
 
784
;****************************************************************************
-
 
785
;    Function
-
 
786
;       linefeed
-
 
787
;
-
 
788
;   Description
-
 
789
;
-
 
790
;
-
 
791
;****************************************************************************
-
 
792
linefeed:
-
 
793
	ret
-
 
794
 
-
 
795
;****************************************************************************
-
 
796
;    Function
-
 
797
;       display_page
-
 
798
;
-
 
799
;   Description
-
 
800
;       Renders the text decoded by draw_page
-
 
801
;
-
 
802
;****************************************************************************
-
 
803
display_page:
-
 
804
	ret
-
 
805
 
-
 
806
;****************************************************************************
-
 
807
;    Function
767
;    Function
808
;       socket_commands
768
;       socket_commands
809
;
769
;
810
;   Description
770
;   Description
811
;       opens or closes the socket
771
;       opens or closes the socket
Line 863... Line 823...
863
tst3:
823
tst3:
864
	cmp	ah,24	; close	socket
824
	cmp	ah,24	; close	socket
865
	jnz	no_24
825
	jnz	no_24
Line 866... Line 826...
866
 
826
 
867
	mcall	53,8,[socket]
-
 
868
	call	draw_page
827
	mcall	53,8,[socket]
869
no_24:
828
no_24:
Line 870... Line 829...
870
	ret
829
	ret
871
 
830
 
Line 1447... Line 1406...
1447
	pop	esi
1406
	pop	esi
1448
	inc	esi
1407
	inc	esi
1449
	jmp	dps_000
1408
	jmp	dps_000
1450
end	if
1409
end	if
Line 1451... Line -...
1451
 
-
 
1452
;****************************************************************************
-
 
1453
;    Function
-
 
1454
;       print_text
-
 
1455
;
-
 
1456
;   Description
-
 
1457
;       display the url (full path) text
-
 
1458
;
-
 
1459
;****************************************************************************
-
 
1460
print_text:
-
 
1461
; Draw a bar to blank out previous text
-
 
1462
	mcall	13, <30,520>, <[ya], 9>,0xFFFFFF
-
 
1463
; write text
-
 
1464
	mcall	4, <30,[ya]>, 0,[addr],URLMAXLEN
-
 
1465
	ret
-
 
1466
 
1410
 
1467
;   *********************************************
1411
;   *********************************************
1468
;   *******  WINDOW DEFINITIONS AND DRAW ********
1412
;   *******  WINDOW DEFINITIONS AND DRAW ********
Line 1469... Line 1413...
1469
;   *********************************************
1413
;   *********************************************
Line 1470... Line -...
1470
 
-
 
1471
draw_window:
-
 
1472
 
1414
 
1473
	mcall	12,1 ; start window redraw
1415
draw_window:
Line 1474... Line 1416...
1474
 
1416
 
1475
;	cmp	[params],byte 0
-
 
1476
;	jz	.noret
-
 
1477
 
-
 
1478
;.noret:
-
 
1479
; DRAW	WINDOW
-
 
1480
	mcall	0,<50,570>,<350,200>,0x14ffffff,0,title
-
 
1481
; eax	function 4: write text to window
-
 
1482
; ebx	[x start] *65536 + [y start]
-
 
1483
; ecx	color of text RRGGBB
-
 
Line -... Line 1417...
-
 
1417
;	cmp	[params],byte 0
-
 
1418
;	jz	.noret
-
 
1419
 
-
 
1420
;.noret:
-
 
1421
 
-
 
1422
	mcall	12,1
-
 
1423
 
-
 
1424
	mcall	48,3,sc,40 ;get system colors
-
 
1425
 
1484
; edx	pointer to text beginning
1426
    mov  edx,[sc.work]
1485
; esi	max lenght
1427
    or   edx,0x34000000
Line 1486... Line 1428...
1486
	xor	ecx,ecx
1428
	mcall	0,<50,370>,<350,140>,,0,title   ;draw window
1487
	mcall	4,<30,38>,,document_user,URLMAXLEN
1429
	
1488
 
1430
    mov  ecx,[sc.work_text]
1489
;	xor	edx,edx
1431
    or	ecx,80000000h	
1490
;	mcall	38,<5,545>,<60,60>
1432
	mcall	4, <14,14>, ,type_pls ;"URL:"
Line -... Line 1433...
-
 
1433
 
-
 
1434
	;mov	ecx,[winys]
-
 
1435
	;shl	ecx,16
1491
 
1436
	;add	ecx,[winys]
1492
;	mov	ecx,[winys]
1437
	;sub	ecx,26*65536+26
1493
;	shl	ecx,16
-
 
1494
;	add	ecx,[winys]
-
 
1495
;	sub	ecx,26*65536+26
1438
	;mcall	38,<5,545>
1496
;	mcall	38,<5,545>
1439
	
1497
 
1440
	edit_boxes_set_sys_color edit1,editboxes_end,sc
1498
; RELOAD
1441
	stdcall [edit_box_draw], edit1
1499
	mcall	8,<388,50>,<54,14>,22,0x5588dd
1442
 
1500
; URL
1443
; RELOAD
-
 
1444
	mcall	8,<90,68>,<54,16>,22,[sc.work_button]
1501
	mcall	,<10,12>,<34,12>,10
1445
; STOP
Line 1502... Line 1446...
1502
; STOP
1446
	mcall	,<166,50>,<54,16>,24
1503
	mcall	,<443,50>,<54,14>,24
1447
; SAVE
1504
; SAVE
1448
	mcall	,<224,54>,,26
1505
	mcall	,<498,50>,,26
1449
; BUTTON TEXT
Line 1542... Line 1486...
1542
str3:		db "Resolved",0
1486
str3:		db "Resolved",0
1543
str2:		db "GotIP",0
1487
str2:		db "GotIP",0
1544
str4:		db "GotResponse",0
1488
str4:		db "GotResponse",0
1545
end	if
1489
end	if
1546
;---------------------------------------------------------------------
1490
;---------------------------------------------------------------------
-
 
1491
;Leency editbox
-
 
1492
mouse_dd dd 0
-
 
1493
edit1 edit_box 295, 48, 10, 0xffffff, 0xff, 0x80ff, 0, 0x8000, URLMAXLEN, document_user, mouse_dd, ed_focus+ed_always_focus,7,7
-
 
1494
editboxes_end:
-
 
1495
 
1547
button_text	db ' RELOAD    STOP     SAVE      '
1496
head_f_i: head_f_l db 'System error',0
-
 
1497
system_dir_0 db '/sys/lib/'
-
 
1498
lib_name_0 db 'box_lib.obj',0
-
 
1499
err_msg_found_lib_0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,0
-
 
1500
err_msg_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,0
-
 
1501
 
-
 
1502
l_libs_start:
1548
dpx		dd 25	; x - start of html page in pixels in window
1503
	lib_0 l_libs lib_name_0, sys_path, library_path, system_dir_0,\
-
 
1504
		err_msg_found_lib_0,head_f_l,import_box_lib,err_msg_import_0,head_f_i
-
 
1505
l_libs_end:
-
 
1506
 
-
 
1507
align 4
-
 
1508
import_box_lib:
1549
dpy		dd 65	; for	y
1509
	;dd sz_init1
-
 
1510
	edit_box_draw dd sz_edit_box_draw
-
 
1511
	edit_box_key dd sz_edit_box_key
-
 
1512
	edit_box_mouse dd sz_edit_box_mouse
-
 
1513
	;edit_box_set_text dd sz_edit_box_set_text
-
 
1514
dd 0,0
-
 
1515
	;sz_init1 db 'lib_init',0
-
 
1516
	sz_edit_box_draw db 'edit_box',0
-
 
1517
	sz_edit_box_key db 'edit_box_key',0
-
 
1518
	sz_edit_box_mouse db 'edit_box_mouse',0
-
 
1519
	;sz_edit_box_set_text db 'edit_box_set_text',0
-
 
1520
 
1550
lastletter	db 0
1521
 sys_path rb 4096
-
 
1522
 library_path rb 4096
-
 
1523
;---------------------------------------------------------------------
-
 
1524
 
1551
pageyinc	dd 0
1525
type_pls	db 'URL:',0	
-
 
1526
button_text	db 'DOWNLOAD     STOP     RESAVE',0
1552
display_from	dd 20
1527
display_from	dd 20
1553
pos		dd 0x0
1528
pos			dd 0x0
1554
pagex		dd 0x0
1529
pagex		dd 0x0
1555
pagey		dd 0x0
1530
pagey		dd 0x0
1556
pagexs		dd 80
1531
pagexs		dd 80
Line 1624... Line 1599...
1624
winys:		dd 400
1599
winys:		dd 400
Line 1625... Line 1600...
1625
 
1600
 
1626
dnsMsgLen:	dd 0
1601
dnsMsgLen:	dd 0
1627
socketNum:	dd 0xFFFF
1602
socketNum:	dd 0xFFFF
1628
;---------------------------------------------------------------------
1603
;---------------------------------------------------------------------
1629
document_user:	db 'Click on the button to the left to enter a URL',0
1604
document_user db 'http://',0
1630
;---------------------------------------------------------------------
1605
;---------------------------------------------------------------------
1631
IM_END:
1606
IM_END:
1632
	rb URLMAXLEN-(IM_END - document_user)
1607
	rb URLMAXLEN-(IM_END - document_user)
1633
;---------------------------------------------------------------------
1608
;---------------------------------------------------------------------