Commit e5c90560 authored by Bernd Paysan's avatar Bernd Paysan

Background-load avatar image if not available

parent 22462bb9
......@@ -432,12 +432,12 @@ glue*avatar >o pixelsize# 64 fm* 0e 0g glue-dup hglue-c glue! vglue-c glue! 0glu
: read-avatar ( addr u -- addr' u' )
?read-enc-hashed mem>thumb atlas-region ;
: show-avatar ( addr u -- o )
: show-avatar ( addr u -- o / 0 )
[: 2dup avatar# #@ nip 0= IF
2dup read-avatar 2swap avatar# #!
ELSE 2drop THEN
glue*avatar last# cell+ $@ drop }}thumb
>r {{ r> }}v 40%b ;] catch IF 2drop THEN ;
>r {{ r> }}v 40%b ;] catch IF 2drop 0 THEN ;
: re-avatar ( last# -- )
>r r@ $@ read-avatar r> cell+ $@ smove ;
......@@ -445,10 +445,22 @@ glue*avatar >o pixelsize# 64 fm* 0e 0g glue-dup hglue-c glue! vglue-c glue! 0glu
:noname defers free-thumbs
avatar# ['] re-avatar #map ; is free-thumbs
event: :>fetch-avatar ( hash u1 pk u2 -- )
$8 $A pk-connect? IF +resend +flow-control
net2o-code expect+slurp $10 blocksize! $A blockalign!
net2o:copy# end-code| net2o:close-all disconnect-me
ELSE 2drop THEN ;
: ?+avatars ( o:key o/0 -- o / )
?dup-0=-IF
<event ke-avatar $@ e$, ke-pk $@ e$, :>fetch-avatar
?query-task event>
THEN ;
: ?avatar ( addr u -- o / )
key# #@ IF
cell+ .ke-avatar $@ dup IF
show-avatar
show-avatar ?dup-0=-IF THEN
ELSE 2drop THEN
ELSE drop THEN ;
......@@ -458,7 +470,8 @@ glue*avatar >o pixelsize# 64 fm* 0e 0g glue-dup hglue-c glue! vglue-c glue! 0glu
{{ glue*l imports#rgb-bg ki + sf@ slide-frame dup .button1
{{
{{ \large imports#rgb-fg ki + sf@ to x-color
ke-avatar $@ dup IF show-avatar ELSE 2drop THEN
ke-avatar $@ dup IF show-avatar ?+avatars
ELSE 2drop THEN
ke-sk sec@ nip IF \bold ELSE \regular THEN \sans
['] .nick-base $tmp }}text 25%b
ke-pets[] $[]# IF
......
......@@ -234,7 +234,7 @@ Variable my-beacon
\G I got a reply, my address is known
beacon( ticks .ticks ." Got known reply: " sockaddr< alen @ .address forth:cr )
sockaddr< alen @ beacons# #@ IF
>r r@ 64@ ticks 64umin beacon-ticks# 64+ r> 64!
>r r@ 64@ ticks 64umin config:beacon-ticks& 2@ d>64 64+ r> 64!
ELSE drop THEN ;
: >-beacon ( addr u -- )
\G I got a punch
......
......@@ -1764,9 +1764,6 @@ event: :>throw ( error -- ) throw ;
\ because that's easier to do.
\ beacons are one-byte packets, with ASCII characters to say what they mean
#50.000.000.000 d>64 64Value beacon-ticks# \ 50s beacon tick rate
#2.000.000.000 d>64 64Value beacon-short-ticks# \ 2s short beacon tick rate
hash: beacons# \ destinations to send beacons to
Variable need-beacon# need-beacon# on \ true if needs a hash for the ? beacon
......@@ -1777,7 +1774,7 @@ Variable need-beacon# need-beacon# on \ true if needs a hash for the ? beacon
beacons# [: dup $@ { baddr u } cell+ $@ drop { beacon }
beacon 64@ ticker 64@ 64u<= IF
beacon( ticks .ticks ." send beacon to: " baddr u .address )
ticker 64@ beacon-short-ticks# 64+ beacon 64!
ticker 64@ config:beacon-short-ticks& 2@ d>64 64+ beacon 64!
net2o-sock
beacon 64'+ @ ?dup-IF
.beacon-hash $@ beacon( ." hash: " 2dup 85type )
......@@ -1793,7 +1790,7 @@ Variable need-beacon# need-beacon# on \ true if needs a hash for the ? beacon
next-beacon ticker 64@ 64u<= IF send-beacons THEN ;
: +beacon ( sockaddr len xt -- )
>r ticks beacon-short-ticks# 64+ o r> { 64^ dest w^ obj w^ xt }
>r ticks config:beacon-short-ticks& 2@ d>64 64+ o r> { 64^ dest w^ obj w^ xt }
beacon( ." add beacon: " 2dup .address ." ' " xt @ .name cr )
2dup beacons# #@ d0= IF
dest 1 64s cell+ cell+ 2swap beacons# #!
......
......@@ -394,6 +394,8 @@ $10 stack: dirstack
scope{ config
2Variable beacon-ticks&
2Variable beacon-short-ticks&
2Variable dht-cleaninterval&
2Variable ekey-timeout&
Variable timeouts#
......@@ -451,6 +453,8 @@ $1000.0000. patchlimit& 2! \ 256MB patch limit size
#10.000.000.000. savedelta& 2! \ 10 seconds deltat
#3600.000.000.000. ekey-timeout& 2! \ one hour ekey timeout
#60.000.000.000. dht-cleaninterval& 2! \ one minute dht clean interval
#50.000.000.000. beacon-ticks& 2!
#2.000.000.000. beacon-short-ticks& 2!
: .net2o-config/ ( addr u -- addr' u' ) [: .net2o-config$ $. '/' emit type ;] $tmp ;
: .net2o-cache/ ( addr u -- addr' u' ) [: .net2o-cache$ $. '/' emit type ;] $tmp ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment