Commit cd363b51 authored by Bernd Paysan's avatar Bernd Paysan

Start image/thumbnail stuff

parent 8aeaf724
......@@ -45,8 +45,8 @@ SOURCES = 64bit.fs base64.fs base85.fs crypto-api.fs debugging.fs \
threefishlib.fs startn2o.fs doc/net2o-logo.png version.fs.in \
android/net.fs android/notify.fs linux/net.fs linux/notify.fs \
dhtroot.fs dvcs.fs qrscan.fs android/qrscan-android.fs \
linux/qrscan-linux.fs doc/net2o-200.png doc/net2o.png doc/user.png \
json/parser.fs json/g+-schema.fs json/g+-import.fs \
linux/qrscan-linux.fs doc/net2o-200.png doc/net2o.png doc/user.png \
doc/thumb.png json/parser.fs json/g+-schema.fs json/g+-import.fs \
json/fb-schema.fs json/twitter-schema.fs json/test.fs \
json/test.json json/diaspora-schema.fs html/parser.fs xml/parser.fs \
xml/blogger-atom.fs
......
......@@ -430,19 +430,32 @@ Hash: avatar#
glue new Constant glue*avatar
glue*avatar >o pixelsize# 64 fm* 0e 0g glue-dup hglue-c glue! vglue-c glue! 0glue dglue-c glue! o>
: glue*thumb ( w h -- o )
glue new >o pixelsize# fm* 0e 0g vglue-c glue!
pixelsize# fm* 0e 0g hglue-c glue! 0glue dglue-c glue! o o> ;
: read-avatar ( addr u -- addr' u' )
?read-enc-hashed mem>thumb atlas-region ;
Variable user-avatar#
Variable dummy-thumb#
Variable user.png$
Variable thumb.png$
: read-user.png ( -- )
"doc/user.png" open-fpath-file throw 2drop
dup >r user.png$ $slurp r> close-file throw ;
: user-avatar ( -- addr u )
: read-thumb.png ( -- )
"doc/thumb.png" open-fpath-file throw 2drop
dup >r thumb.png$ $slurp r> close-file throw ;
: user-avatar ( -- addr )
user-avatar# @ 0= IF
read-user.png user.png$ $@ mem>thumb atlas-region
user-avatar# $!
THEN user-avatar# $@ ;
THEN user-avatar# $@ drop ;
: dummy-thumb ( -- addr )
dummy-thumb# @ 0= IF
read-thumb.png thumb.png$ $@ mem>thumb atlas-region
dummy-thumb# $!
THEN dummy-thumb# $@ drop ;
: avatar-thumb ( avatar -- )
glue*avatar swap }}thumb >r {{ r> }}v 40%b ;
: avatar-frame ( addr u -- frame# )
......@@ -461,16 +474,16 @@ Variable user.png$
event: :>update-avatar ( thumb hash u1 -- )
avatar-frame swap .childs[] $@ drop @ >o to frame# o>
['] +sync peers-box .vp-needed +sync ;
event: :>fetch-avatar { thumb up hash u1 pk u2 -- }
event: :>fetch-avatar { thumb task hash u1 pk u2 -- }
pk u2 $8 $A pk-connect? IF +resend +flow-control
net2o-code expect+slurp $10 blocksize! $A blockalign!
hash u1 net2o:copy# end-code| net2o:close-all disconnect-me
<event thumb elit, hash u1 e$, :>update-avatar up event>
<event thumb elit, hash u1 e$, :>update-avatar task event>
ELSE 2drop THEN ;
: ?+avatars ( o:key o/0 -- o )
?dup-0=-IF
user-avatar drop avatar-thumb
user-avatar avatar-thumb
<event dup elit, up@ elit,
ke-avatar $@ e$, ke-pk $@ e$, :>fetch-avatar
?query-task event>
......@@ -490,7 +503,7 @@ event: :>fetch-avatar { thumb up hash u1 pk u2 -- }
{{
{{ \large imports#rgb-fg ki + sf@ to x-color
ke-avatar $@ dup IF show-avatar ?+avatars
ELSE 2drop user-avatar drop avatar-thumb THEN
ELSE 2drop user-avatar avatar-thumb THEN
ke-sk sec@ nip IF \bold ELSE \regular THEN \sans
['] .nick-base $tmp }}text 25%b
ke-pets[] $[]# IF
......@@ -1019,20 +1032,43 @@ Variable emojis$ "👍👎🤣😍😘😛🤔😭😡😱🔃" emojis$ $! \
THEN
LOOP
THEN ; wmsg-class is msg:otrify
Hash: thumbs#
: thumb-frame ( addr u -- o )
keysize safe/string key|
2dup thumbs# #@ nip 0= IF
2dup read-avatar 2swap thumbs# #!
ELSE 2drop THEN last# cell+ $@ drop ;
: ?thumb ( addr u -- o )
2dup ['] thumb-frame catch 0= IF
>r 2drop r@ i.w r@ i.h glue*thumb r> }}thumb
EXIT THEN
2drop
128 128 glue*thumb dummy-thumb }}thumb >r
<event ['] drop elit, msg:id$ e$, e$,
:>fetch-thumb ?query-task event> r> ;
:noname ( addr u type -- )
obj-red
[: case 0 >r
msg:image# of ." img[" 85type endof
msg:thumbnail# of ." thumb[" 85type endof
msg:patch# of ." patch[" 85type endof
msg:snapshot# of ." snapshot[" 85type endof
msg:message# of ." message[" 85type endof
msg:posting# of ." posting"
rdrop 2dup [d:h open-posting ;] >r
.posting
endof
endcase ." ]" r> ;] $tmp }}text
swap ?dup-IF 0 click[] THEN
case 0 >r
msg:image# of [: ." img[" 2dup 85type ']' emit
;] $tmp }}text >r
<event ['] noop elit, msg:id$ e$, e$,
:>fetch-img ?query-task event> r> endof
msg:thumbnail# of ?thumb endof
msg:patch# of [: ." patch[" 85type ']' emit
;] $tmp }}text endof
msg:snapshot# of [: ." snapshot[" 85type ']' emit
;] $tmp }}text endof
msg:message# of [: ." message[" 85type ']' emit
;] $tmp }}text endof
msg:posting# of ." posting"
rdrop 2dup [d:h open-posting ;] >r
['] .posting $tmp }}text
endof
endcase r> ?dup-IF 0 click[] THEN
"object" name! msg-box .child+
text-color!
; wmsg-class is msg:object
......
......@@ -476,10 +476,29 @@ scope: logstyles
perm [ 1 64s ]L pk msg-group-o .msg:perms# #!
pk .key-id ." : " perm 64@ 64>n .perms space
; msg-class is msg:perms
event: :>fetch-img { xt: action d: pk d: hash }
pk $8 $E pk-connect? IF +resend +flow-control
net2o-code expect+slurp $10 blocksize! $A blockalign!
hash key| net2o:copy# end-code| net2o:close-all disconnect-me
action
ELSE 2drop THEN ;
event: :>fetch-thumb { xt: action d: pk d: hash }
pk $8 $E pk-connect? IF +resend +flow-control
net2o-code expect+slurp $10 blocksize! $A blockalign!
hash keysize safe/string key| net2o:copy#
hash key| net2o:copy# end-code| net2o:close-all disconnect-me
hash keysize 2* safe/string drop c@ action
ELSE 2drop THEN ;
:noname ( addr u type -- )
space <warn> case
msg:image# of ." img[" 85type endof
msg:thumbnail# of ." thumb[" 85type endof
msg:image# of ." img[" 2dup 85type
<event ['] noop elit, msg:id$ e$, e$,
:>fetch-img ?query-task event> endof
msg:thumbnail# of ." thumb[" 85type ( 2dup 85type
<event ['] drop elit, msg:id$ e$, e$,
:>fetch-thumb ?query-task event> ) endof
msg:patch# of ." patch[" 85type endof
msg:snapshot# of ." snapshot[" 85type endof
msg:message# of ." message[" 85type endof
......
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